public class ExpressionBuilder extends Object
Constructor and Description |
---|
ExpressionBuilder(ModelFactory factory,
Expression context)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
ExpressionBuilder |
apply(InfixOperator operator,
Expression right)
Returns a binary expression which contains the building expression on the left term.
|
ExpressionBuilder |
apply(PostfixOperator operator)
Returns a postfix expression.
|
ExpressionBuilder |
apply(UnaryOperator operator)
Returns a unary expression.
|
ExpressionBuilder |
array(Expression index)
Returns an array access expression which contains the building expression as the target array.
|
ExpressionBuilder |
array(int index)
Returns an array access expression which contains the building expression as the target array.
|
ExpressionBuilder |
array(String index)
Returns an array access expression which contains the building expression as the target array.
|
ExpressionBuilder |
assignFrom(Expression rightHandSide)
Returns an assignment expression which contains the building expression on the left hand side.
|
ExpressionBuilder |
assignFrom(InfixOperator operator,
Expression rightHandSide)
Returns an assignment expression which contains the building expression on the left hand side.
|
ExpressionBuilder |
castTo(Type type)
Returns a cast expression.
|
ExpressionBuilder |
castTo(Type type)
Returns a cast expression.
|
ExpressionBuilder |
copy()
Returns a copy of this builder.
|
ExpressionBuilder |
field(SimpleName name)
Returns a field access expression which take the building expression as its owner object.
|
ExpressionBuilder |
field(String name)
Returns a field access expression which take the building expression as its owner object.
|
ExpressionBuilder |
instanceOf(Type type)
Returns an
instanceof expression. |
ExpressionBuilder |
instanceOf(Type type)
Returns an
instanceof expression. |
ExpressionBuilder |
method(List<? extends Type> typeArguments,
SimpleName name,
Expression... arguments)
Returns the method invocation which take the building expression as its receiver object.
|
ExpressionBuilder |
method(List<? extends Type> typeArguments,
SimpleName name,
List<? extends Expression> arguments)
Returns the method invocation which take the building expression as its receiver object.
|
ExpressionBuilder |
method(List<? extends Type> typeArguments,
String name,
Expression... arguments)
Returns the method invocation which take the building expression as its receiver object.
|
ExpressionBuilder |
method(List<? extends Type> typeArguments,
String name,
List<? extends Expression> arguments)
Returns the method invocation which take the building expression as its receiver object.
|
ExpressionBuilder |
method(SimpleName name,
Expression... arguments)
Returns the method invocation which take the building expression as its receiver object.
|
ExpressionBuilder |
method(SimpleName name,
List<? extends Expression> arguments)
Returns the method invocation which take the building expression as its receiver object.
|
ExpressionBuilder |
method(String name,
Expression... arguments)
Returns the method invocation which take the building expression as its receiver object.
|
ExpressionBuilder |
method(String name,
List<? extends Expression> arguments)
Returns the method invocation which take the building expression as its receiver object.
|
ExpressionBuilder |
methodReference(List<? extends Type> typeArguments,
SimpleName name)
Returns the method invocation using the building expression as its qualifier.
|
ExpressionBuilder |
methodReference(List<? extends Type> typeArguments,
String name)
Returns the method invocation using the building expression as its qualifier.
|
ExpressionBuilder |
methodReference(SimpleName name)
Returns the method reference using the building expression as its qualifier.
|
ExpressionBuilder |
methodReference(String name)
Returns the method reference using the building expression as its qualifier.
|
Expression |
toExpression()
Returns the built expression.
|
LocalVariableDeclaration |
toLocalVariableDeclaration(Type type,
SimpleName name)
Returns a local variable declaration which is initialized by the built expression.
|
LocalVariableDeclaration |
toLocalVariableDeclaration(Type type,
String name)
Returns a local variable declaration which is initialized by the built expression.
|
ReturnStatement |
toReturnStatement()
Returns a
return statement which passes the built expression. |
ExpressionStatement |
toStatement()
Returns the built expression as expression statement.
|
ThrowStatement |
toThrowStatement()
Returns a
throw statement which throws the built expression. |
public ExpressionBuilder(ModelFactory factory, Expression context)
factory
- the Java DOM factorycontext
- the context expressionIllegalArgumentException
- if the parameters are null
public ExpressionBuilder copy()
public Expression toExpression()
public ExpressionStatement toStatement()
public ThrowStatement toThrowStatement()
throw
statement which throws the built expression.throw
statement which throws the built expressionpublic ReturnStatement toReturnStatement()
return
statement which passes the built expression.return
statement which passes the built expressionpublic LocalVariableDeclaration toLocalVariableDeclaration(Type type, String name)
type
- the variable typename
- the variable nameIllegalArgumentException
- if the parameters are null
public LocalVariableDeclaration toLocalVariableDeclaration(Type type, SimpleName name)
type
- the variable typename
- the variable nameIllegalArgumentException
- if the parameters are null
public ExpressionBuilder apply(InfixOperator operator, Expression right)
operator
- the infix operatorright
- the right termIllegalArgumentException
- if the parameters are null
public ExpressionBuilder apply(UnaryOperator operator)
operator
- the unary operatorIllegalArgumentException
- if the parameter is null
public ExpressionBuilder apply(PostfixOperator operator)
operator
- the postfix operatorIllegalArgumentException
- if the parameter is null
public ExpressionBuilder assignFrom(Expression rightHandSide)
rightHandSide
- the right hand side expressionIllegalArgumentException
- if the parameter is null
public ExpressionBuilder assignFrom(InfixOperator operator, Expression rightHandSide)
operator
- infix operator for compound assignmentrightHandSide
- the right hand side expressionIllegalArgumentException
- if the parameter is null
public ExpressionBuilder castTo(Type type)
type
- the target typeIllegalArgumentException
- if the parameter is null
public ExpressionBuilder castTo(Type type)
type
- the target typeIllegalArgumentException
- if the parameter is null
public ExpressionBuilder instanceOf(Type type)
instanceof
expression.type
- the target typeIllegalArgumentException
- if the parameter is null
public ExpressionBuilder instanceOf(Type type)
instanceof
expression.type
- the target typeIllegalArgumentException
- if the parameter is null
public ExpressionBuilder field(String name)
name
- the target field nameIllegalArgumentException
- if the parameter is null
public ExpressionBuilder field(SimpleName name)
name
- the target field nameIllegalArgumentException
- if the parameter is null
public ExpressionBuilder array(int index)
index
- the indexpublic ExpressionBuilder array(String index)
index
- the index variable nameIllegalArgumentException
- if the parameter is null
public ExpressionBuilder array(Expression index)
index
- the index expressionIllegalArgumentException
- if the parameter is null
public ExpressionBuilder method(String name, Expression... arguments)
name
- the target method namearguments
- the method argumentsIllegalArgumentException
- the parameters are null
public ExpressionBuilder method(List<? extends Type> typeArguments, String name, Expression... arguments)
typeArguments
- the type argumentsname
- the target method namearguments
- the method argumentsIllegalArgumentException
- the parameters are null
public ExpressionBuilder method(String name, List<? extends Expression> arguments)
name
- the target method namearguments
- the method argumentsIllegalArgumentException
- the parameters are null
public ExpressionBuilder method(List<? extends Type> typeArguments, String name, List<? extends Expression> arguments)
typeArguments
- the type argumentsname
- the target method namearguments
- the method argumentsIllegalArgumentException
- the parameters are null
public ExpressionBuilder method(SimpleName name, Expression... arguments)
name
- the target method namearguments
- the method argumentsIllegalArgumentException
- the parameters are null
public ExpressionBuilder method(List<? extends Type> typeArguments, SimpleName name, Expression... arguments)
typeArguments
- the type argumentsname
- the target method namearguments
- the method argumentsIllegalArgumentException
- the parameters are null
public ExpressionBuilder method(SimpleName name, List<? extends Expression> arguments)
name
- the target method namearguments
- the method argumentsIllegalArgumentException
- the parameters are null
public ExpressionBuilder method(List<? extends Type> typeArguments, SimpleName name, List<? extends Expression> arguments)
typeArguments
- the type argumentsname
- the target method namearguments
- the method argumentsIllegalArgumentException
- the parameters are null
public ExpressionBuilder methodReference(String name)
name
- the target method nameIllegalArgumentException
- if the parameters are null
public ExpressionBuilder methodReference(SimpleName name)
name
- the target method nameIllegalArgumentException
- if the parameters are null
public ExpressionBuilder methodReference(List<? extends Type> typeArguments, String name)
typeArguments
- the type argumentsname
- the target method nameIllegalArgumentException
- if the parameters are null
public ExpressionBuilder methodReference(List<? extends Type> typeArguments, SimpleName name)
typeArguments
- the type argumentsname
- the target method nameIllegalArgumentException
- if the parameters are null
Copyright © 2011–2019 Asakusa Framework Team. All rights reserved.