public final class JInvocation extends JExpressionImpl implements JStatement
Modifier and Type | Field and Description |
---|---|
private java.util.List<JExpression> |
args
List of argument expressions for this method invocation
|
private 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 invocation
|
private JType |
type
If isConstructor==true, this field keeps the type to be created.
|
Modifier | Constructor and 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.)
|
Modifier and Type | Method and Description |
---|---|
JInvocation |
arg(JExpression arg)
Add an expression to this invocation's argument list
|
JInvocation |
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) |
private JGenerable object
private java.lang.String name
method
, or type
(in which case it's a
constructor invocation.)
This allows the name of the method to be changed later
.private JMethod method
private boolean isConstructor
private java.util.List<JExpression> args
private JType type
JInvocation(JExpression object, java.lang.String name)
object
- JExpression for the object upon which
the named method will be invoked,
or null if nonename
- Name of method to invokeJInvocation(JExpression object, JMethod method)
JInvocation(JClass type, java.lang.String name)
private JInvocation(JGenerable object, java.lang.String name)
private JInvocation(JGenerable object, JMethod method)
JInvocation(JType c)
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 like
new int[]{1,2,3,4,5}
.public JInvocation arg(JExpression arg)
arg
- Argument to add to argument listpublic JInvocation arg(java.lang.String v)
arg(JExpr.lit(v))
public JExpression[] listArgs()
public void generate(JFormatter f)
generate
in interface JGenerable
public void state(JFormatter f)
state
in interface JStatement