Class DefaultTypeTransformation
java.lang.Object
org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation
Class providing various type conversions, coercions and boxing/unboxing operations.
- Author:
- Guillaume Laforge
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Object[]protected static final BigInteger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CollectionarrayAsCollection(Object value) static <T> Collection<T>arrayAsCollection(T[] value) static Objectstatic CollectionasCollection(Object value) static <T> Collection<T>asCollection(T[] value) static booleanbooleanUnbox(Object value) static Objectbox(boolean value) static Objectbox(byte value) static Objectbox(char value) static Objectbox(double value) static Objectbox(float value) static Objectbox(int value) static Objectbox(long value) static Objectbox(short value) static bytestatic booleancastToBoolean(Object object) Method used for coercing an object to a boolean value, thanks to anasBoolean()method added on types.static charcastToChar(Object object) static NumbercastToNumber(Object object) static NumbercastToNumber(Object object, Class type) static ObjectcastToType(Object object, Class type) static charstatic booleancompareArrayEqual(Object left, Object right) static booleancompareEqual(Object left, Object right) static intCompares the two objects handling nulls gracefully and performing numeric type coercion if requiredstatic boolean[]static byte[]static char[]static double[]static float[]static int[]static long[]static ObjectconvertToPrimitiveArray(Object a, Class type) static short[]static doubledoubleUnbox(Object value) static floatfloatUnbox(Object value) static CharactergetCharFromSizeOneString(Object value) static intstatic booleanisEnumSubclass(Object value) Determines whether the value object is a Class object representing a subclass of java.lang.Enum.static longstatic Object[]primitiveArrayBox(Object array) static ListprimitiveArrayToList(Object array) Allows conversion of arrays into a mutable Liststatic shortshortUnbox(Object value)
-
Field Details
-
EMPTY_ARGUMENTS
-
ONE_NEG
-
-
Constructor Details
-
DefaultTypeTransformation
public DefaultTypeTransformation()
-
-
Method Details
-
byteUnbox
-
charUnbox
-
shortUnbox
-
intUnbox
-
booleanUnbox
-
longUnbox
-
floatUnbox
-
doubleUnbox
-
box
-
box
-
box
-
box
-
box
-
box
-
box
-
box
-
castToNumber
-
castToNumber
-
castToBoolean
Method used for coercing an object to a boolean value, thanks to anasBoolean()method added on types.- Parameters:
object- to coerce to a boolean value- Returns:
- a boolean value
-
castToChar
-
castToType
-
asArray
-
asCollection
-
asCollection
-
arrayAsCollection
-
arrayAsCollection
-
isEnumSubclass
Determines whether the value object is a Class object representing a subclass of java.lang.Enum. Uses class name check to avoid breaking on pre-Java 5 JREs.- Parameters:
value- an object- Returns:
- true if the object is an Enum
-
primitiveArrayToList
Allows conversion of arrays into a mutable List- Parameters:
array- an array- Returns:
- the array as a List
-
primitiveArrayBox
-
compareTo
Compares the two objects handling nulls gracefully and performing numeric type coercion if required -
compareEqual
-
compareArrayEqual
-
convertToIntArray
-
convertToBooleanArray
-
convertToByteArray
-
convertToShortArray
-
convertToCharArray
-
convertToLongArray
-
convertToFloatArray
-
convertToDoubleArray
-
convertToPrimitiveArray
-
getCharFromSizeOneString
-