|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.codehaus.groovy.ast.tools.WideningCategories
public class WideningCategories extends java.lang.Object
This class provides helper methods to determine the type from a widening
operation for example for a plus operation.
To determine the resulting type of for example a=exp1+exp2 we look at the
conditions isIntCategory(ClassNode), isLongCategory(ClassNode),
isBigIntCategory(ClassNode), isDoubleCategory(ClassNode) and
isBigDecCategory(ClassNode) in that order. The first case applying to
exp1 and exp2 is defining the result type of the expression.
If for example you look at x = 1 + 2l we have the first category applying to
the number 1 being int, since the 1 is an int. The 2l is a long, therefore the
int category will not apply and the result type can't be int. The next category
in the list is long, and since both apply to long, the result type is a long.
Nested Class Summary | |
---|---|
static class |
WideningCategories.LowestUpperBoundClassNode
This ClassNode specialization is used when the lowest upper bound of two types cannot be represented by an existing type. |
Method Summary | |
---|---|
static boolean
|
isBigDecCategory(ClassNode type)
It is of a BigDecimal category, if the provided type is a BigInteger category or a BigDecimal. |
static boolean
|
isBigIntCategory(ClassNode type)
It is of a BigInteger category, if the provided type is a long category or a BigInteger. |
static boolean
|
isDouble(ClassNode type)
Used to check if a type is an double or Double. |
static boolean
|
isDoubleCategory(ClassNode type)
It is of a double category, if the provided type is a BigDecimal, a float, double. |
static boolean
|
isFloat(ClassNode type)
Used to check if a type is a float or Float. |
static boolean
|
isFloatingCategory(ClassNode type)
It is of a floating category, if the provided type is a a float, double. |
static boolean
|
isInt(ClassNode type)
Used to check if a type is an int or Integer. |
static boolean
|
isIntCategory(ClassNode type)
It is of an int category, if the provided type is a byte, char, short, int. |
static boolean
|
isLongCategory(ClassNode type)
It is of a long category, if the provided type is a long, its wrapper or if it is a long category. |
static boolean
|
isNumberCategory(ClassNode type)
|
static ClassNode
|
lowestUpperBound(java.util.List nodes)
Given a list of class nodes, returns the first common supertype. |
static ClassNode
|
lowestUpperBound(ClassNode a, ClassNode b)
Given two class nodes, returns the first common supertype, or the class itself if there are equal. |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Method Detail |
---|
public static boolean isBigDecCategory(ClassNode type)
public static boolean isBigIntCategory(ClassNode type)
public static boolean isDouble(ClassNode type)
type
- the type to check
public static boolean isDoubleCategory(ClassNode type)
public static boolean isFloat(ClassNode type)
type
- the type to check
public static boolean isFloatingCategory(ClassNode type)
public static boolean isInt(ClassNode type)
type
- the type to check
public static boolean isIntCategory(ClassNode type)
public static boolean isLongCategory(ClassNode type)
public static boolean isNumberCategory(ClassNode type)
public static ClassNode lowestUpperBound(java.util.List nodes)
nodes
- the list of nodes for which to find the first common super type.
public static ClassNode lowestUpperBound(ClassNode a, ClassNode b)
a
- first class nodeb
- second class node
Groovy Documentation