Class DefaultTypeTransformation
java.lang.Object
org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation
Class providing various type conversions, coercions and boxing/unboxing operations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Object[]Deprecated, for removal: This API element is subject to removal in a future version.protected static final BigIntegerDeprecated, for removal: This API element is subject to removal in a future version. -
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) Deprecated.static Objectbox(byte value) Deprecated.static Objectbox(char value) Deprecated.static Objectbox(double value) Deprecated.static Objectbox(float value) Deprecated.static Objectbox(int value) Deprecated.static Objectbox(long value) Deprecated.static Objectbox(short value) Deprecated.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) Deprecated.static NumbercastToNumber(Object object) static NumbercastToNumber(Object object, Class type) static ObjectcastToType(Object object, Class type) static ObjectcastToVargsArray(Object[] origin, int firstVargsPos, Class<?> arrayType) 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[]Deprecated.static byte[]Deprecated.static char[]Deprecated.static double[]Deprecated.static float[]Deprecated.static int[]Deprecated.static long[]Deprecated.static ObjectconvertToPrimitiveArray(Object a, Class type) Deprecated.static short[]Deprecated.static doubledoubleUnbox(Object value) static floatfloatUnbox(Object value) static CharactergetCharFromSizeOneString(Object value) Deprecated.static intstatic booleanisEnumSubclass(Object value) Deprecated.static longstatic Object[]primitiveArrayBox(Object array) static ListprimitiveArrayToList(Object array) Allows conversion of arrays into a mutable Liststatic ListAllows conversion of arrays into an immutable List viewstatic shortshortUnbox(Object value)
-
Field Details
-
EMPTY_ARGUMENTS
Deprecated, for removal: This API element is subject to removal in a future version. -
ONE_NEG
Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Constructor Details
-
DefaultTypeTransformation
public DefaultTypeTransformation()
-
-
Method Details
-
byteUnbox
-
charUnbox
-
shortUnbox
-
intUnbox
-
booleanUnbox
-
longUnbox
-
floatUnbox
-
doubleUnbox
-
box
Deprecated. -
box
Deprecated. -
box
Deprecated. -
box
Deprecated. -
box
Deprecated. -
box
Deprecated. -
box
Deprecated. -
box
Deprecated. -
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
Deprecated. -
castToType
-
asArray
-
asCollection
-
asCollection
-
arrayAsCollection
-
arrayAsCollection
-
isEnumSubclass
Deprecated.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
-
primitiveArrayToUnmodifiableList
Allows conversion of arrays into an immutable List view- Parameters:
array- an array- Returns:
- a List view of the array
-
primitiveArrayBox
-
compareTo
Compares the two objects handling nulls gracefully and performing numeric type coercion if required -
compareEqual
-
compareArrayEqual
-
convertToIntArray
Deprecated. -
convertToBooleanArray
Deprecated. -
convertToByteArray
Deprecated. -
convertToShortArray
Deprecated. -
convertToCharArray
Deprecated. -
convertToLongArray
Deprecated. -
convertToFloatArray
Deprecated. -
convertToDoubleArray
Deprecated. -
convertToPrimitiveArray
Deprecated. -
getCharFromSizeOneString
Deprecated. -
castToVargsArray
-