Package io.activej.codegen.expression
Class Expressions
java.lang.Object
io.activej.codegen.expression.Expressions
public class Expressions extends Object
Defines list of possibilities for creating dynamic objects
-
Constructor Summary
Constructors Constructor Description Expressions() -
Method Summary
Modifier and Type Method Description static Expressionadd(Expression left, Expression right)Returns sum of argumentsstatic ExpressionalwaysFalse()static ExpressionalwaysTrue()static Expressionand(Expression... predicateDefs)static Expressionand(Expression predicate1, Expression predicate2)static Expressionand(List<Expression> predicateDefs)Returns result of logical 'and' for the list of predicatesstatic Expressionand(Stream<Expression> predicateDefs)static Variablearg(int argument)Returns value which ordinal number is 'argument'static ExpressionarithmeticOp(ArithmeticOperation op, Expression left, Expression right)static ExpressionarithmeticOp(String op, Expression left, Expression right)static ExpressionarrayGet(Expression array, Expression nom)static ExpressionarrayNew(Class<?> type, Expression length)static ExpressionarraySet(Expression array, Expression position, Expression newElement)static ExpressionbitAnd(Expression left, Expression right)static ExpressionbitOr(Expression left, Expression right)static ExpressionbitXor(Expression left, Expression right)static Expressioncall(Expression owner, String methodName, Expression... arguments)Returns a newexpression callwhich allows to use static methods from other classesstatic Expressioncast(Expression expression, Class<?> type)Casts expression to the typestatic ExpressioncastIntoSelf(Expression expression)static Expressioncmp(CompareOperation eq, Expression left, Expression right)Compares argumentsstatic ExpressioncmpEq(Expression left, Expression right)Verifies that the arguments are equalstatic ExpressioncmpGe(Expression left, Expression right)static ExpressioncmpGt(Expression left, Expression right)static ExpressioncmpLe(Expression left, Expression right)static ExpressioncmpLt(Expression left, Expression right)static ExpressioncmpNe(Expression left, Expression right)static Expressioncompare(Class<?> type, String... properties)Compares the propertiesstatic Expressioncompare(Class<?> type, List<String> properties)Compares the propertiesstatic ExpressioncompareToImpl(String... properties)Compares the propertiesstatic ExpressioncompareToImpl(List<String> properties)Compares the propertiesstatic io.activej.codegen.expression.ExpressionConstructorconstructor(Class<?> type, Expression... fields)Returns new instance of classstatic Expressiondec(Expression value)static Expressiondiv(Expression left, Expression right)static ExpressionequalsImpl(String... properties)Verifies that the properties are equalstatic ExpressionequalsImpl(List<String> properties)Verifies that the properties are equalstatic Expressionexception(Class<? extends Throwable> exception)static Expressionexception(Class<? extends Throwable> exception, Expression message)static ExpressionforEach(Expression collection, Class<?> type, Function<Expression,Expression> it)static ExpressionforEach(Expression collection, Function<Expression,Expression> it)static ExpressionforEach(Expression collection, Function<Expression,Expression> forEachKey, Function<Expression,Expression> forEachValue)static Expressionhash(Expression... properties)Returns a hash code which was calculated from thepropertiesstatic Expressionhash(List<Expression> properties)Returns a hash code which was calculated from thepropertiesstatic ExpressionhashCodeImpl(String... properties)static ExpressionhashCodeImpl(List<String> properties)Returns hash of the propertiesstatic ExpressionifThenElse(Expression condition, Expression left, Expression right)static Expressioninc(Expression value)static ExpressionisNotNull(Expression field)static ExpressionisNull(Expression field)static Expressionlength(Expression field)static Expressionlet(Expression[] expressions, Function<Variable[],Expression> fn)static Expressionlet(Expression expression, Function<Variable,Expression> fn)static Expressionlet(List<Expression> expressions, Function<List<Variable>,Expression> fn)static Expressionloop(Expression from, Expression to, Function<Expression,Expression> it)static Expressionmul(Expression left, Expression right)static Expressionneg(Expression arg)static Expressionnot(Expression expression)static ExpressionnullRef(Class<?> type)static ExpressionnullRef(org.objectweb.asm.Type type)static io.activej.codegen.expression.ExpressionBooleanOror(Expression... predicateDefs)static io.activej.codegen.expression.ExpressionBooleanOror(Expression predicate1, Expression predicate2)static io.activej.codegen.expression.ExpressionBooleanOror(List<Expression> predicateDefs)Returns result of logical 'or' for the list of predicatesstatic io.activej.codegen.expression.ExpressionBooleanOror(Stream<Expression> predicateDefs)static Variableproperty(Expression owner, String property)Returns the property fromownerstatic Expressionrem(Expression left, Expression right)static Expressionself()Returns current instancestatic Expressionsequence(Expression... parts)Returns sequence of operations which will be processed one after the otherstatic Expressionsequence(Consumer<List<Expression>> consumer)static Expressionsequence(List<Expression> parts)static Expressionset(StoreDef to, Expression from)Sets the value from the argument 'from' to the argument 'to'static Expressionshl(Expression left, Expression right)static Expressionshr(Expression left, Expression right)static ExpressionstaticCall(Class<?> owner, String method, Expression... arguments)static ExpressionstaticCallSelf(String method, Expression... arguments)static VariablestaticField(Class<?> owner, String field)Returns the static field fromownerstatic VariablestaticField(String field)static Expressionsub(Expression left, Expression right)static ExpressionswitchByIndex(Expression index, Expression... expressions)static ExpressionswitchByIndex(Expression index, List<Expression> expressions)static ExpressionswitchByIndex(Expression index, List<Expression> expressions, Expression defaultExpression)static ExpressionswitchByKey(Expression key, List<Expression> matchCases, List<Expression> matchExpressions)static ExpressionswitchByKey(Expression key, List<Expression> matchCases, List<Expression> matchExpressions, Expression defaultExpression)static ExpressionswitchByKey(Expression key, Map<Expression,Expression> cases)static ExpressionswitchByKey(Expression key, Map<Expression,Expression> cases, Expression defaultExpression)static ExpressiontoStringImpl(String... properties)Returns the string which was constructed from propertiesstatic ExpressiontoStringImpl(List<String> properties)Returns the string which was constructed from propertiesstatic Class<?>unifyArithmeticTypes(Class<?>... types)static Class<?>unifyArithmeticTypes(List<Class<?>> types)static Expressionushr(Expression left, Expression right)static Expressionvalue(Object value)Returns new constant for the valuestatic Expressionvalue(Object value, Class<?> type)static ExpressionvoidExp()
-
Constructor Details
-
Expressions
public Expressions()
-
-
Method Details
-
value
Returns new constant for the value- Parameters:
value- value which will be created as constant- Returns:
- new instance of the ExpressionConstant
-
value
-
sequence
Returns sequence of operations which will be processed one after the other- Parameters:
parts- list of operations- Returns:
- new instance of the ExpressionSequence
-
sequence
-
sequence
-
let
-
let
public static Expression let(List<Expression> expressions, Function<List<Variable>,Expression> fn) -
let
-
set
Sets the value from the argument 'from' to the argument 'to'- Parameters:
to- variable which will be changedfrom- variable which changes- Returns:
- new instance of the Expression
-
cast
Casts expression to the type- Parameters:
expression- expressions which will be castedtype- expression will be casted to the 'type'- Returns:
- new instance of the Expression which is casted to the type
-
castIntoSelf
-
property
Returns the property fromowner- Parameters:
owner- owner of the propertyproperty- name of the property which will be returned- Returns:
- new instance of the Property
-
staticField
Returns the static field fromowner- Parameters:
owner- owner of the fieldfield- name of the static field which will be returned- Returns:
- new instance of the ExpressionStaticField
-
staticField
-
self
Returns current instance- Returns:
- current instance of the Expression
-
arg
Returns value which ordinal number is 'argument'- Parameters:
argument- ordinal number in list of arguments- Returns:
- new instance of the VarArg
-
alwaysFalse
-
alwaysTrue
-
not
-
cmp
Compares arguments- Parameters:
eq- operation which will be used for the argumentsleft- first argument which will be comparedright- second argument which will be compared- Returns:
- new instance of the PredicateDefCmp
-
cmpEq
Verifies that the arguments are equal- Parameters:
left- first argument which will be comparedright- second argument which will be compared- Returns:
- new instance of the PredicateDefCmp
-
cmpGe
-
cmpLe
-
cmpLt
-
cmpGt
-
cmpNe
-
and
Returns result of logical 'and' for the list of predicates- Parameters:
predicateDefs- list of the predicate- Returns:
- new instance of the PredicateDefAnd
-
and
-
and
-
and
-
or
Returns result of logical 'or' for the list of predicates- Parameters:
predicateDefs- list of the predicate- Returns:
- new instance of the PredicateDefOr
-
or
public static io.activej.codegen.expression.ExpressionBooleanOr or(Stream<Expression> predicateDefs) -
or
-
or
public static io.activej.codegen.expression.ExpressionBooleanOr or(Expression predicate1, Expression predicate2) -
equalsImpl
Verifies that the properties are equal- Parameters:
properties- list of the properties- Returns:
- new instance of the Expression
-
equalsImpl
Verifies that the properties are equal- Parameters:
properties- list of the properties- Returns:
- new instance of the Expression
-
toStringImpl
Returns the string which was constructed from properties- Parameters:
properties- list of the properties- Returns:
- new instance of the ExpressionToString
-
toStringImpl
Returns the string which was constructed from properties- Parameters:
properties- list of the properties- Returns:
- new instance of the ExpressionToString
-
compare
Compares the properties- Parameters:
type- type of the propertiesproperties- properties which will be compared- Returns:
- new instance of the ExpressionComparator
-
compare
Compares the properties- Parameters:
type- type of the propertiesproperties- properties which will be compared- Returns:
- new instance of the ExpressionComparator
-
compareToImpl
Compares the properties- Parameters:
properties- list of the properties with will be compared- Returns:
- new instance of the ExpressionComparator
-
compareToImpl
Compares the properties- Parameters:
properties- list of the properties with will be compared- Returns:
- new instance of the ExpressionComparator
-
hash
Returns a hash code which was calculated from theproperties- Parameters:
properties- list of the properties which will be hashed- Returns:
- new instance of the ExpressionHash
-
hash
Returns a hash code which was calculated from theproperties- Parameters:
properties- list of the properties which will be hashed- Returns:
- new instance of the ExpressionHash
-
hashCodeImpl
-
hashCodeImpl
Returns hash of the properties- Parameters:
properties- list of the properties which will be hashed- Returns:
- new instance of the ExpressionHash
-
unifyArithmeticTypes
-
unifyArithmeticTypes
-
arithmeticOp
-
arithmeticOp
-
add
Returns sum of arguments- Parameters:
left- first argument which will be addedright- second argument which will be added- Returns:
- new instance of the ExpressionArithmeticOp
-
inc
-
sub
-
dec
-
mul
-
div
-
rem
-
bitAnd
-
bitOr
-
bitXor
-
shl
-
shr
-
ushr
-
constructor
public static io.activej.codegen.expression.ExpressionConstructor constructor(Class<?> type, Expression... fields)Returns new instance of class- Parameters:
type- type of the constructorfields- fields for constructor- Returns:
- new instance of the ExpressionConstructor
-
call
Returns a newexpression callwhich allows to use static methods from other classes- Parameters:
owner- owner of the methodmethodName- name of the method in the classarguments- list of the arguments for the method- Returns:
- new instance of the ExpressionCall
-
ifThenElse
-
length
-
arrayNew
-
staticCall
-
staticCallSelf
-
arrayGet
-
isNull
-
isNotNull
-
nullRef
-
nullRef
-
voidExp
-
exception
-
exception
-
switchByIndex
-
switchByIndex
-
switchByIndex
public static Expression switchByIndex(Expression index, List<Expression> expressions, Expression defaultExpression) -
switchByKey
public static Expression switchByKey(Expression key, List<Expression> matchCases, List<Expression> matchExpressions) -
switchByKey
public static Expression switchByKey(Expression key, List<Expression> matchCases, List<Expression> matchExpressions, Expression defaultExpression) -
switchByKey
-
switchByKey
public static Expression switchByKey(Expression key, Map<Expression,Expression> cases, Expression defaultExpression) -
arraySet
-
forEach
-
forEach
public static Expression forEach(Expression collection, Class<?> type, Function<Expression,Expression> it) -
loop
-
forEach
public static Expression forEach(Expression collection, Function<Expression,Expression> forEachKey, Function<Expression,Expression> forEachValue) -
neg
-