public final class ExpressionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
isNullConstant(Expression expr) |
static boolean |
isNumberOrArrayOfNumber(ClassNode targetType,
boolean recurse)
Determine if a type is derived from Number (or array thereof).
|
static boolean |
isSuperExpression(Expression expression) |
static boolean |
isThisExpression(Expression expression) |
static boolean |
isThisOrSuper(Expression expression) |
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)
The attribute values of annotations must be primitive, String or Enum constants.
|
static Expression |
transformInlineConstants(Expression exp,
ClassNode attrType)
Converts simple expressions of constants into pre-evaluated simple constants.
|
static Expression |
transformListOfConstants(ListExpression origList,
ClassNode attrType)
Given a list of constants, transform each item in the list.
|
public static ConstantExpression transformBinaryConstantExpression(BinaryExpression be, ClassNode targetType)
be
- the binary expressiontargetType
- the type of the resultpublic static boolean isTypeOrArrayOfType(ClassNode targetType, ClassNode type, boolean recurse)
targetType
- the candidate typetype
- the type we are checking againstrecurse
- true if we can have multi-dimension arrays; should be false for annotation member typespublic static boolean isNumberOrArrayOfNumber(ClassNode targetType, boolean recurse)
targetType
- the candidate typerecurse
- true if we can have multi-dimension arrays; should be false for annotation member typespublic static Expression transformInlineConstants(Expression exp, ClassNode attrType)
exp
- the original expressionattrType
- the type that the final constant should bepublic static Expression transformListOfConstants(ListExpression origList, ClassNode attrType)
origList
- the list to transformattrType
- the target typepublic static Expression transformInlineConstants(Expression exp)
exp
- the original expressionpublic static boolean isThisExpression(Expression expression)
public static boolean isSuperExpression(Expression expression)
public static boolean isThisOrSuper(Expression expression)
public static boolean isNullConstant(Expression expr)