public final class ObjectCreationExpr extends Expression implements NodeWithTypeArguments<ObjectCreationExpr>, NodeWithType<ObjectCreationExpr,ClassOrInterfaceType>, NodeWithArguments<ObjectCreationExpr>, NodeWithOptionalScope<ObjectCreationExpr>
new HashMap.Entry<String, Long>(15) {public String getKey() {return null;}};
HashMap.Entry is the type, String and Long are type arguments, 15 is an argument, and everything in { }
is the anonymous class body.
In class B { class C { public void a() { new B().new C(); } } }
the scope is new B()
of ObjectCreationExpr new B().new C()
Node.ObserverRegistrationMode, Node.Parsedness
Modifier and Type | Field and Description |
---|---|
private NodeList<BodyDeclaration<?>> |
anonymousClassBody |
private NodeList<Expression> |
arguments |
private Expression |
scope |
private ClassOrInterfaceType |
type |
private NodeList<Type> |
typeArguments |
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration
Constructor and Description |
---|
ObjectCreationExpr() |
ObjectCreationExpr(Expression scope,
ClassOrInterfaceType type,
NodeList<Expression> arguments)
Defines a call to a constructor.
|
ObjectCreationExpr(Expression scope,
ClassOrInterfaceType type,
NodeList<Type> typeArguments,
NodeList<Expression> arguments,
NodeList<BodyDeclaration<?>> anonymousClassBody) |
ObjectCreationExpr(TokenRange tokenRange,
Expression scope,
ClassOrInterfaceType type,
NodeList<Type> typeArguments,
NodeList<Expression> arguments,
NodeList<BodyDeclaration<?>> anonymousClassBody)
This constructor is used by the parser and is considered private.
|
Modifier and Type | Method and Description |
---|---|
<R,A> R |
accept(GenericVisitor<R,A> v,
A arg)
Accept method for visitor support.
|
<A> void |
accept(VoidVisitor<A> v,
A arg)
Accept method for visitor support.
|
void |
addAnonymousClassBody(BodyDeclaration<?> body) |
ObjectCreationExpr |
clone() |
java.util.Optional<NodeList<BodyDeclaration<?>>> |
getAnonymousClassBody() |
NodeList<Expression> |
getArguments() |
ObjectCreationExprMetaModel |
getMetaModel() |
java.util.List<NodeList<?>> |
getNodeLists()
The list of NodeLists owned by this node.
|
java.util.Optional<Expression> |
getScope() |
ClassOrInterfaceType |
getType()
Gets the type
|
java.util.Optional<NodeList<Type>> |
getTypeArguments() |
boolean |
remove(Node node) |
ObjectCreationExpr |
removeScope() |
boolean |
replace(Node node,
Node replacementNode) |
ObjectCreationExpr |
setAnonymousClassBody(NodeList<BodyDeclaration<?>> anonymousClassBody)
Sets the anonymousClassBody
Null means no class body Empty NodeList means new ClassName(){ } |
ObjectCreationExpr |
setArguments(NodeList<Expression> arguments) |
ObjectCreationExpr |
setScope(Expression scope)
Sets the scope
|
ObjectCreationExpr |
setType(ClassOrInterfaceType type)
Sets the type
|
ObjectCreationExpr |
setTypeArguments(NodeList<Type> typeArguments)
Sets the typeArguments
|
addOrphanComment, customInitialization, equals, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getTokenRange, hasComment, hashCode, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, toString, toString, tryAddImportToParentCompilationUnit, unregister
finalize, getClass, notify, notifyAll, wait, wait, wait
isUsingDiamondOperator, removeTypeArguments, setDiamondOperator, setTypeArguments
setType, setType, tryAddImportToParentCompilationUnit
addArgument, addArgument, getArgument, setArgument
getAncestorOfType
containsWithin, getBegin, getEnd, isPositionedAfter, isPositionedBefore
private Expression scope
private ClassOrInterfaceType type
private NodeList<Expression> arguments
private NodeList<BodyDeclaration<?>> anonymousClassBody
public ObjectCreationExpr()
public ObjectCreationExpr(Expression scope, ClassOrInterfaceType type, NodeList<Expression> arguments)
scope
- may be nulltype
- this is the class that the constructor is being called for.arguments
- Any arguments to pass to the constructorpublic ObjectCreationExpr(Expression scope, ClassOrInterfaceType type, NodeList<Type> typeArguments, NodeList<Expression> arguments, NodeList<BodyDeclaration<?>> anonymousClassBody)
@Generated(value="com.github.javaparser.generator.core.node.MainConstructorGenerator") public ObjectCreationExpr(TokenRange tokenRange, Expression scope, ClassOrInterfaceType type, NodeList<Type> typeArguments, NodeList<Expression> arguments, NodeList<BodyDeclaration<?>> anonymousClassBody)
public <R,A> R accept(GenericVisitor<R,A> v, A arg)
Visitable
accept
in interface Visitable
R
- the type of the return value of the visitorA
- the type the user argument passed to the visitorv
- the visitor implementationarg
- the argument passed to the visitor (of type A)public <A> void accept(VoidVisitor<A> v, A arg)
Visitable
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public java.util.Optional<NodeList<BodyDeclaration<?>>> getAnonymousClassBody()
public void addAnonymousClassBody(BodyDeclaration<?> body)
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public NodeList<Expression> getArguments()
getArguments
in interface NodeWithArguments<ObjectCreationExpr>
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public java.util.Optional<Expression> getScope()
getScope
in interface NodeWithOptionalScope<ObjectCreationExpr>
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public ClassOrInterfaceType getType()
NodeWithType
getType
in interface NodeWithType<ObjectCreationExpr,ClassOrInterfaceType>
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public ObjectCreationExpr setAnonymousClassBody(NodeList<BodyDeclaration<?>> anonymousClassBody)
anonymousClassBody
- the anonymousClassBody, can be null or empty@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public ObjectCreationExpr setArguments(NodeList<Expression> arguments)
setArguments
in interface NodeWithArguments<ObjectCreationExpr>
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public ObjectCreationExpr setScope(Expression scope)
setScope
in interface NodeWithOptionalScope<ObjectCreationExpr>
scope
- the scope, can be null@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public ObjectCreationExpr setType(ClassOrInterfaceType type)
NodeWithType
setType
in interface NodeWithType<ObjectCreationExpr,ClassOrInterfaceType>
type
- the type@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public java.util.Optional<NodeList<Type>> getTypeArguments()
getTypeArguments
in interface NodeWithTypeArguments<ObjectCreationExpr>
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public ObjectCreationExpr setTypeArguments(NodeList<Type> typeArguments)
setTypeArguments
in interface NodeWithTypeArguments<ObjectCreationExpr>
typeArguments
- the typeArguments, can be null@Generated(value="com.github.javaparser.generator.core.node.GetNodeListsGenerator") public java.util.List<NodeList<?>> getNodeLists()
Node
getNodeLists
in class Node
@Generated(value="com.github.javaparser.generator.core.node.RemoveMethodGenerator") public boolean remove(Node node)
remove
in class Expression
@Generated(value="com.github.javaparser.generator.core.node.RemoveMethodGenerator") public ObjectCreationExpr removeScope()
removeScope
in interface NodeWithOptionalScope<ObjectCreationExpr>
@Generated(value="com.github.javaparser.generator.core.node.CloneGenerator") public ObjectCreationExpr clone()
clone
in class Expression
@Generated(value="com.github.javaparser.generator.core.node.GetMetaModelGenerator") public ObjectCreationExprMetaModel getMetaModel()
getMetaModel
in class Expression
@Generated(value="com.github.javaparser.generator.core.node.ReplaceMethodGenerator") public boolean replace(Node node, Node replacementNode)
replace
in class Expression