Package: org.codehaus.groovy.runtime.typehandling

## [Java] Class ShortTypeHandling

- org.codehaus.groovy.runtime.typehandling.ShortTypeHandling

-     public class ShortTypeHandling
      extends Object

  High-performance type casting and conversion utilities.

  Provides fast-path type conversions for common cases. These methods are designed to avoid dependency on the Groovy runtime and should be used directly only when the type constraints documented in each method are met.

  For general-purpose type coercion, use DefaultTypeTransformation instead.

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static Character` | `castToChar(Object object)` Casts an object to a char value (Character wrapper).
    `` | `public static Class` | `castToClass(Object object)` Casts an object to a Class object.
    `` | `public static Enum` | `castToEnum(Object object, Class<? extends Enum> type)` Casts an object to an Enum value of the specified type.
    `` | `public static String` | `castToString(Object object)` Casts an object to a String representation.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public static Character castToChar(Object object)

      Casts an object to a char value (Character wrapper).

      Accepts Character objects, Numbers (converted via intValue), or Strings of length 1.

      throws:
        GroovyCastException if the object cannot be converted to char
      Parameters:
        `object` - a Character, Number, or single-character String
      Returns:
        a Character with the coerced value, or null if input is null

    - #### public static Class castToClass(Object object)

      Casts an object to a Class object.

      Accepts Class objects directly, or a string representation of a class name which is loaded via `Class.forName`.

      throws:
        GroovyCastException if the object is not a Class or valid class name
      Parameters:
        `object` - a Class object or string class name
      Returns:
        the Class object, or null if input is null

    - #### public static Enum castToEnum(Object object, Class<? extends Enum> type)

      Casts an object to an Enum value of the specified type.

      Note: This method requires that the supplied enum is not fitting a Collection case for casting.

      Accepts Enum objects already of the correct type, or a String/GString representation of the enum constant name.

      throws:
        GroovyCastException if the object cannot be converted to the enum type
      Parameters:
        `object` - an enum value, or a string enum constant name
        `type` - the target enum class
      Returns:
        the Enum value, or null if input is null

    - #### public static String castToString(Object object)

      Casts an object to a String representation.

      Arrays are converted using `Arrays.toString` format. Primitive arrays receive special handling to show element values. Other objects use their standard `toString()` method.

      Parameters:
        `object` - any object (may be null)
      Returns:
        string representation, or null if input is null