Skip to content

Commit

Permalink
Added a useful constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
matozoid committed Oct 26, 2017
1 parent 05e1056 commit e4c3401
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Expand Up @@ -60,10 +60,14 @@ public NodeList(Node parent) {
setParentNode(parent); setParentNode(parent);
} }


public NodeList(NodeList<N> n) { public NodeList(Collection<N> n) {
this.addAll(n); this.addAll(n);
} }


public NodeList(N... n) {
this.addAll(Arrays.asList(n));
}

@Override @Override
public boolean add(N node) { public boolean add(N node) {
notifyElementAdded(innerList.size(), node); notifyElementAdded(innerList.size(), node);
Expand Down
Expand Up @@ -30,8 +30,6 @@
import com.github.javaparser.ast.type.Type; import com.github.javaparser.ast.type.Type;
import com.github.javaparser.ast.visitor.GenericVisitor; import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor; import com.github.javaparser.ast.visitor.VoidVisitor;
import java.util.Arrays;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import static com.github.javaparser.utils.Utils.assertNotNull; import static com.github.javaparser.utils.Utils.assertNotNull;
import com.github.javaparser.ast.Node; import com.github.javaparser.ast.Node;
Expand Down Expand Up @@ -62,6 +60,10 @@ public MethodCallExpr() {
this(null, null, new NodeList<>(), new SimpleName(), new NodeList<>()); this(null, null, new NodeList<>(), new SimpleName(), new NodeList<>());
} }


public MethodCallExpr(String name, Expression... arguments) {
this(null, null, new NodeList<>(), new SimpleName(name), new NodeList<>(arguments));
}

public MethodCallExpr(final Expression scope, final String name) { public MethodCallExpr(final Expression scope, final String name) {
this(null, scope, new NodeList<>(), new SimpleName(name), new NodeList<>()); this(null, scope, new NodeList<>(), new SimpleName(name), new NodeList<>());
} }
Expand Down

0 comments on commit e4c3401

Please sign in to comment.