Package com.sun.codemodel
Class JInvocation
- java.lang.Object
-
- com.sun.codemodel.JExpressionImpl
-
- com.sun.codemodel.JInvocation
-
- All Implemented Interfaces:
JExpression
,JGenerable
,JStatement
public final class JInvocation extends JExpressionImpl implements JStatement
JMethod invocation
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<JExpression>
args
List of argument expressions for this method invocationprivate boolean
isConstructor
private JMethod
method
private java.lang.String
name
Name of the method to be invoked.private JGenerable
object
Object expression upon which this method will be invoked, or null if this is a constructor invocationprivate JType
type
If isConstructor==true, this field keeps the type to be created.
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
JInvocation(JClass type, JMethod method)
(package private)
JInvocation(JClass type, java.lang.String name)
Invokes a static method on a class.(package private)
JInvocation(JExpression object, JMethod method)
(package private)
JInvocation(JExpression object, java.lang.String name)
Invokes a method on an object.private
JInvocation(JGenerable object, JMethod method)
private
JInvocation(JGenerable object, java.lang.String name)
(package private)
JInvocation(JType c)
Invokes a constructor of an object (i.e., creates a new object.)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JInvocation
arg(JExpression arg)
Add an expression to this invocation's argument listJInvocation
arg(java.lang.String v)
Adds a literal argument.void
generate(JFormatter f)
JExpression[]
listArgs()
Returns all arguments of the invocation.void
state(JFormatter f)
-
-
-
Field Detail
-
object
private JGenerable object
Object expression upon which this method will be invoked, or null if this is a constructor invocation
-
name
private java.lang.String name
Name of the method to be invoked. Either this field is set, ormethod
, ortype
(in which case it's a constructor invocation.) This allowsthe name of the method to be changed later
.
-
method
private JMethod method
-
isConstructor
private boolean isConstructor
-
args
private java.util.List<JExpression> args
List of argument expressions for this method invocation
-
type
private JType type
If isConstructor==true, this field keeps the type to be created.
-
-
Constructor Detail
-
JInvocation
JInvocation(JExpression object, java.lang.String name)
Invokes a method on an object.- Parameters:
object
- JExpression for the object upon which the named method will be invoked, or null if nonename
- Name of method to invoke
-
JInvocation
JInvocation(JExpression object, JMethod method)
-
JInvocation
JInvocation(JClass type, java.lang.String name)
Invokes a static method on a class.
-
JInvocation
private JInvocation(JGenerable object, java.lang.String name)
-
JInvocation
private JInvocation(JGenerable object, JMethod method)
-
JInvocation
JInvocation(JType c)
Invokes a constructor of an object (i.e., creates a new object.)- Parameters:
c
- Type of the object to be created. If this type is an array type, added arguments are treated as array initializer. Thus you can create an expression likenew int[]{1,2,3,4,5}
.
-
-
Method Detail
-
arg
public JInvocation arg(JExpression arg)
Add an expression to this invocation's argument list- Parameters:
arg
- Argument to add to argument list
-
arg
public JInvocation arg(java.lang.String v)
Adds a literal argument. Short forarg(JExpr.lit(v))
-
listArgs
public JExpression[] listArgs()
Returns all arguments of the invocation.- Returns:
- If there's no arguments, an empty array will be returned.
-
generate
public void generate(JFormatter f)
- Specified by:
generate
in interfaceJGenerable
-
state
public void state(JFormatter f)
- Specified by:
state
in interfaceJStatement
-
-