public class ExpressionUtils extends Object
Type Params | Return Type | Name and description |
---|---|---|
|
static boolean |
isNumberOrArrayOfNumber(ClassNode targetType, boolean recurse) Determine if a type is derived from Number (or array thereof). |
|
static boolean |
isTypeOrArrayOfType(ClassNode targetType, ClassNode type, boolean recurse) Determine if a type matches another type (or array thereof). |
|
static ConstantExpression |
transformBinaryConstantExpression(BinaryExpression be, ClassNode targetType) Turns expressions of the form ConstantExpression(40) + ConstantExpression(2) into the simplified ConstantExpression(42) at compile time. |
|
static Expression |
transformInlineConstants(Expression exp, ClassNode attrType) Converts simple expressions of constants into pre-evaluated simple constants. |
|
static Expression |
transformInlineConstants(Expression exp) The attribute values of annotations must be primitive, String or Enum constants. |
|
static Expression |
transformListOfConstants(ListExpression origList, ClassNode attrType) Given a list of constants, transform each item in the list. |
Determine if a type is derived from Number (or array thereof).
targetType
- the candidate typerecurse
- true if we can have multi-dimension arrays; should be false for annotation member typesDetermine if a type matches another type (or array thereof).
targetType
- the candidate typetype
- the type we are checking againstrecurse
- true if we can have multi-dimension arrays; should be false for annotation member typesTurns expressions of the form ConstantExpression(40) + ConstantExpression(2) into the simplified ConstantExpression(42) at compile time.
be
- the binary expressiontargetType
- the type of the resultConverts simple expressions of constants into pre-evaluated simple constants. Handles:
exp
- the original expressionattrType
- the type that the final constant should beThe attribute values of annotations must be primitive, String or Enum constants. In various places, such constants can be seen during type resolution but won't be readily accessible in later phases, e.g. they might be embedded into constructor code. This method transforms constants that would appear in annotations early so they aren't lost. Subsequent processing determines whether they are valid, this method simply retains the constant value as a constant expression.
exp
- the original expressionGiven a list of constants, transform each item in the list.
origList
- the list to transformattrType
- the target type