Groovy Documentation

## org.codehaus.groovy.runtime.typehandling
[Java] Class DefaultTypeTransformation

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

    public class DefaultTypeTransformation
    extends java.lang.Object

Class providing various type conversions, coercions and boxing/unboxing operations.

Authors:
  Guillaume Laforge

Field Summary
`protected static java.lang.Object[]` | `EMPTY_ARGUMENTS`
`protected static java.math.BigInteger` | `ONE_NEG`

Method Summary
`static java.util.Collection` | `arrayAsCollection(java.lang.Object value)` Determines whether the value object is a Class object representing a subclass of java.lang.Enum.
`static java.util.Collection` | `arrayAsCollection(java.lang.Object[] value)`
`static java.lang.Object` | `asArray(java.lang.Object object, java.lang.Class type)`
`static java.util.Collection` | `asCollection(java.lang.Object[] value)`
`static java.util.Collection` | `asCollection(java.lang.Object value)`
`static boolean` | `booleanUnbox(java.lang.Object value)`
`static java.lang.Object` | `box(boolean value)`
`static java.lang.Object` | `box(byte value)`
`static java.lang.Object` | `box(char value)`
`static java.lang.Object` | `box(short value)`
`static java.lang.Object` | `box(int value)`
`static java.lang.Object` | `box(long value)`
`static java.lang.Object` | `box(float value)`
`static java.lang.Object` | `box(double value)`
`static byte` | `byteUnbox(java.lang.Object value)`
`static boolean` | `castToBoolean(java.lang.Object object)` Method used for coercing an object to a boolean value, thanks to an `asBoolean()` method added on types.
`static char` | `castToChar(java.lang.Object object)`
`static java.lang.Number` | `castToNumber(java.lang.Object object)`
`static java.lang.Number` | `castToNumber(java.lang.Object object, java.lang.Class type)`
`static java.lang.Object` | `castToType(java.lang.Object object, java.lang.Class type)`
`static char` | `charUnbox(java.lang.Object value)`
`static boolean` | `compareArrayEqual(java.lang.Object left, java.lang.Object right)` @return true if the given value is a valid character string (i.e. has length of 1)
`static boolean` | `compareEqual(java.lang.Object left, java.lang.Object right)`
`static int` | `compareTo(java.lang.Object left, java.lang.Object right)`
`static boolean[]` | `convertToBooleanArray(java.lang.Object a)`
`static byte[]` | `convertToByteArray(java.lang.Object a)`
`static char[]` | `convertToCharArray(java.lang.Object a)`
`static double[]` | `convertToDoubleArray(java.lang.Object a)`
`static float[]` | `convertToFloatArray(java.lang.Object a)`
`static int[]` | `convertToIntArray(java.lang.Object a)`
`static long[]` | `convertToLongArray(java.lang.Object a)`
`static java.lang.Object` | `convertToPrimitiveArray(java.lang.Object a, java.lang.Class type)`
`static short[]` | `convertToShortArray(java.lang.Object a)`
`static double` | `doubleUnbox(java.lang.Object value)`
`static float` | `floatUnbox(java.lang.Object value)`
`static java.lang.Character` | `getCharFromSizeOneString(java.lang.Object value)`
`static int` | `intUnbox(java.lang.Object value)`
`static boolean` | `isEnumSubclass(java.lang.Object value)`
`static long` | `longUnbox(java.lang.Object value)`
`static java.lang.Object[]` | `primitiveArrayBox(java.lang.Object array)`
`static java.util.List` | `primitiveArrayToList(java.lang.Object array)` Compares the two objects handling nulls gracefully and performing numeric type coercion if required
`static short` | `shortUnbox(java.lang.Object value)`

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()

Field Detail

### EMPTY_ARGUMENTS

    protected static final java.lang.Object[] EMPTY_ARGUMENTS

### ONE_NEG

    protected static final java.math.BigInteger ONE_NEG

Method Detail

### arrayAsCollection

    public static java.util.Collection arrayAsCollection(java.lang.Object value)

  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

### arrayAsCollection

    public static java.util.Collection arrayAsCollection(java.lang.Object[] value)

### asArray

    public static java.lang.Object asArray(java.lang.Object object, java.lang.Class type)

### asCollection

    public static java.util.Collection asCollection(java.lang.Object[] value)

### asCollection

    public static java.util.Collection asCollection(java.lang.Object value)

### booleanUnbox

    public static boolean booleanUnbox(java.lang.Object value)

### box

    public static java.lang.Object box(boolean value)

### box

    public static java.lang.Object box(byte value)

### box

    public static java.lang.Object box(char value)

### box

    public static java.lang.Object box(short value)

### box

    public static java.lang.Object box(int value)

### box

    public static java.lang.Object box(long value)

### box

    public static java.lang.Object box(float value)

### box

    public static java.lang.Object box(double value)

### byteUnbox

    public static byte byteUnbox(java.lang.Object value)

### castToBoolean

    public static boolean castToBoolean(java.lang.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

    public static char castToChar(java.lang.Object object)

### castToNumber

    public static java.lang.Number castToNumber(java.lang.Object object)

### castToNumber

    public static java.lang.Number castToNumber(java.lang.Object object, java.lang.Class type)

### castToType

    public static java.lang.Object castToType(java.lang.Object object, java.lang.Class type)

### charUnbox

    public static char charUnbox(java.lang.Object value)

### compareArrayEqual

    public static boolean compareArrayEqual(java.lang.Object left, java.lang.Object right)

  Returns:
    true if the given value is a valid character string (i.e. has length of 1)

### compareEqual

    public static boolean compareEqual(java.lang.Object left, java.lang.Object right)

### compareTo

    public static int compareTo(java.lang.Object left, java.lang.Object right)

### convertToBooleanArray

    public static boolean[] convertToBooleanArray(java.lang.Object a)

### convertToByteArray

    public static byte[] convertToByteArray(java.lang.Object a)

### convertToCharArray

    public static char[] convertToCharArray(java.lang.Object a)

### convertToDoubleArray

    public static double[] convertToDoubleArray(java.lang.Object a)

### convertToFloatArray

    public static float[] convertToFloatArray(java.lang.Object a)

### convertToIntArray

    public static int[] convertToIntArray(java.lang.Object a)

### convertToLongArray

    public static long[] convertToLongArray(java.lang.Object a)

### convertToPrimitiveArray

    public static java.lang.Object convertToPrimitiveArray(java.lang.Object a, java.lang.Class type)

### convertToShortArray

    public static short[] convertToShortArray(java.lang.Object a)

### doubleUnbox

    public static double doubleUnbox(java.lang.Object value)

### floatUnbox

    public static float floatUnbox(java.lang.Object value)

### getCharFromSizeOneString

    public static java.lang.Character getCharFromSizeOneString(java.lang.Object value)

### intUnbox

    public static int intUnbox(java.lang.Object value)

### isEnumSubclass

    public static boolean isEnumSubclass(java.lang.Object value)

### longUnbox

    public static long longUnbox(java.lang.Object value)

### primitiveArrayBox

    public static java.lang.Object[] primitiveArrayBox(java.lang.Object array)

### primitiveArrayToList

    public static java.util.List primitiveArrayToList(java.lang.Object array)

  Compares the two objects handling nulls gracefully and performing numeric type coercion if required

### shortUnbox

    public static short shortUnbox(java.lang.Object value)

Groovy Documentation