Package org.codehaus.groovy.runtime.typehandling

# Class DefaultTypeTransformation

java.lang.Object
org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation

public class DefaultTypeTransformation extends Object
Class providing various type conversions, coercions and boxing/unboxing operations.

Author:
  Guillaume Laforge

## Field Summary

Fields
Modifier and Type
Field
Description
`protected static final Object[]`
`EMPTY_ARGUMENTS`
`protected static final BigInteger`
`ONE_NEG`

## Constructor Summary

Constructors
Constructor
Description
`DefaultTypeTransformation()`

## Method Summary

Modifier and Type
Method
Description
`static Collection`
`arrayAsCollection(Object value)`
`static <T> Collection<T>`
`arrayAsCollection(T[] value)`
`static Object`
`asArray(Object object, Class type)`
`static Collection`
`asCollection(Object value)`
`static <T> Collection<T>`
`asCollection(T[] value)`
`static boolean`
`booleanUnbox(Object value)`
`static Object`
`box(boolean value)`
Deprecated.
`static Object`
`box(byte value)`
Deprecated.
`static Object`
`box(char value)`
Deprecated.
`static Object`
`box(double value)`
Deprecated.
`static Object`
`box(float value)`
Deprecated.
`static Object`
`box(int value)`
Deprecated.
`static Object`
`box(long value)`
Deprecated.
`static Object`
`box(short value)`
Deprecated.
`static byte`
`byteUnbox(Object value)`
`static boolean`
`castToBoolean(Object object)`
Method used for coercing an object to a boolean value, thanks to an `asBoolean()` method added on types.
`static char`
`castToChar(Object object)`
Deprecated.
`static Number`
`castToNumber(Object object)`
`static Number`
`castToNumber(Object object, Class type)`
`static Object`
`castToType(Object object, Class type)`
`static Object`
`castToVargsArray(Object[] origin, int firstVargsPos, Class<?> arrayType)`
`static char`
`charUnbox(Object value)`
`static boolean`
`compareArrayEqual(Object left, Object right)`
`static boolean`
`compareEqual(Object left, Object right)`
`static int`
`compareTo(Object left, Object right)`
Compares the two objects handling nulls gracefully and performing numeric type coercion if required
`static boolean[]`
`convertToBooleanArray(Object a)`
Deprecated.
`static byte[]`
`convertToByteArray(Object a)`
Deprecated.
`static char[]`
`convertToCharArray(Object a)`
Deprecated.
`static double[]`
`convertToDoubleArray(Object a)`
Deprecated.
`static float[]`
`convertToFloatArray(Object a)`
Deprecated.
`static int[]`
`convertToIntArray(Object a)`
Deprecated.
`static long[]`
`convertToLongArray(Object a)`
Deprecated.
`static Object`
`convertToPrimitiveArray(Object a, Class type)`
Deprecated.
`static short[]`
`convertToShortArray(Object a)`
Deprecated.
`static double`
`doubleUnbox(Object value)`
`static float`
`floatUnbox(Object value)`
`static Character`
`getCharFromSizeOneString(Object value)`
Deprecated.
`static int`
`intUnbox(Object value)`
`static boolean`
`isEnumSubclass(Object value)`
Deprecated.
`static long`
`longUnbox(Object value)`
`static Object[]`
`primitiveArrayBox(Object array)`
`static List`
`primitiveArrayToList(Object array)`
Allows conversion of arrays into a mutable List
`static short`
`shortUnbox(Object value)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### EMPTY_ARGUMENTS

protected static final Object[] EMPTY_ARGUMENTS

### ONE_NEG

protected static final BigInteger ONE_NEG

## Constructor Details

### DefaultTypeTransformation

public DefaultTypeTransformation()

## Method Details

### byteUnbox

public static byte byteUnbox(Object value)

### charUnbox

public static char charUnbox(Object value)

### shortUnbox

public static short shortUnbox(Object value)

### intUnbox

public static int intUnbox(Object value)

### booleanUnbox

public static boolean booleanUnbox(Object value)

### longUnbox

public static long longUnbox(Object value)

### floatUnbox

public static float floatUnbox(Object value)

### doubleUnbox

public static double doubleUnbox(Object value)

### box

@Deprecated public static Object box(boolean value)
Deprecated.

### box

@Deprecated public static Object box(byte value)
Deprecated.

### box

@Deprecated public static Object box(char value)
Deprecated.

### box

@Deprecated public static Object box(short value)
Deprecated.

### box

@Deprecated public static Object box(int value)
Deprecated.

### box

@Deprecated public static Object box(long value)
Deprecated.

### box

@Deprecated public static Object box(float value)
Deprecated.

### box

@Deprecated public static Object box(double value)
Deprecated.

### castToNumber

public static Number castToNumber(Object object)

### castToNumber

public static Number castToNumber(Object object, Class type)

### castToBoolean

public static boolean castToBoolean(Object object)
Method used for coercing an object to a boolean value, thanks to an `asBoolean()` method added on types.

Parameters:
  `object` - to coerce to a boolean value
Returns:
  a boolean value

### castToChar

@Deprecated public static char castToChar(Object object)
Deprecated.

### castToType

public static Object castToType(Object object, Class type)

### asArray

public static Object asArray(Object object, Class type)

### asCollection

public static <T> Collection<T> asCollection(T[] value)

### asCollection

public static Collection asCollection(Object value)

### arrayAsCollection

public static Collection arrayAsCollection(Object value)

### arrayAsCollection

public static <T> Collection<T> arrayAsCollection(T[] value)

### isEnumSubclass

@Deprecated public static boolean isEnumSubclass(Object value)
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

public static List primitiveArrayToList(Object array)
Allows conversion of arrays into a mutable List

Parameters:
  `array` - an array
Returns:
  the array as a List

### primitiveArrayBox

public static Object[] primitiveArrayBox(Object array)

### compareTo

public static int compareTo(Object left, Object right)
Compares the two objects handling nulls gracefully and performing numeric type coercion if required

### compareEqual

public static boolean compareEqual(Object left, Object right)

### compareArrayEqual

public static boolean compareArrayEqual(Object left, Object right)

### convertToIntArray

@Deprecated public static int[] convertToIntArray(Object a)
Deprecated.

### convertToBooleanArray

@Deprecated public static boolean[] convertToBooleanArray(Object a)
Deprecated.

### convertToByteArray

@Deprecated public static byte[] convertToByteArray(Object a)
Deprecated.

### convertToShortArray

@Deprecated public static short[] convertToShortArray(Object a)
Deprecated.

### convertToCharArray

@Deprecated public static char[] convertToCharArray(Object a)
Deprecated.

### convertToLongArray

@Deprecated public static long[] convertToLongArray(Object a)
Deprecated.

### convertToFloatArray

@Deprecated public static float[] convertToFloatArray(Object a)
Deprecated.

### convertToDoubleArray

@Deprecated public static double[] convertToDoubleArray(Object a)
Deprecated.

### convertToPrimitiveArray

@Deprecated public static Object convertToPrimitiveArray(Object a, Class type)
Deprecated.

### getCharFromSizeOneString

@Deprecated public static Character getCharFromSizeOneString(Object value)
Deprecated.

### castToVargsArray

public static Object castToVargsArray(Object[] origin, int firstVargsPos, Class<?> arrayType)