Package com.sun.codemodel
Class JInvocation
java.lang.Object
com.sun.codemodel.JExpressionImpl
com.sun.codemodel.JInvocation
- All Implemented Interfaces:
JExpression
,JGenerable
,JStatement
JMethod invocation
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List
<JExpression> List of argument expressions for this method invocationprivate boolean
private JMethod
private String
Name of the method to be invoked.private JGenerable
Object expression upon which this method will be invoked, or null if this is a constructor invocationprivate JType
If isConstructor==true, this field keeps the type to be created. -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
JInvocation
(JClass type, JMethod method) (package private)
JInvocation
(JClass type, String name) Invokes a static method on a class.(package private)
JInvocation
(JExpression object, JMethod method) (package private)
JInvocation
(JExpression object, String name) Invokes a method on an object.private
JInvocation
(JGenerable object, JMethod method) private
JInvocation
(JGenerable object, String name) (package private)
JInvocation
(JType c) Invokes a constructor of an object (i.e., creates a new object.) -
Method Summary
Modifier and TypeMethodDescriptionarg
(JExpression arg) Add an expression to this invocation's argument listAdds a literal argument.void
listArgs()
Returns all arguments of the invocation.void
state
(JFormatter f)
-
Field Details
-
object
Object expression upon which this method will be invoked, or null if this is a constructor invocation -
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
-
isConstructor
private boolean isConstructor -
args
List of argument expressions for this method invocation -
type
If isConstructor==true, this field keeps the type to be created.
-
-
Constructor Details
-
JInvocation
JInvocation(JExpression object, 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
Invokes a static method on a class. -
JInvocation
-
JInvocation
-
JInvocation
-
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 Details
-
arg
Add an expression to this invocation's argument list- Parameters:
arg
- Argument to add to argument list
-
arg
Adds a literal argument. Short forarg(JExpr.lit(v))
-
listArgs
Returns all arguments of the invocation.- Returns:
- If there's no arguments, an empty array will be returned.
-
generate
- Specified by:
generate
in interfaceJGenerable
-
state
- Specified by:
state
in interfaceJStatement
-