Package org.codehaus.groovy.reflection.stdclasses

# Class DoubleCachedClass

java.lang.Object
org.codehaus.groovy.reflection.CachedClass
org.codehaus.groovy.reflection.stdclasses.NumberCachedClass
org.codehaus.groovy.reflection.stdclasses.DoubleCachedClass

Direct Known Subclasses:
  `BigDecimalCachedClass`

public class DoubleCachedClass extends NumberCachedClass
Provides optimized reflection caching for `double` and `Double`. Coerces numeric arguments to double values, with validation to prevent overflow to infinity. Optionally allows `null` values for the boxed `Double` class variant.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.codehaus.groovy.reflection.CachedClass

  `CachedClass.CachedMethodComparatorByName, CachedClass.CachedMethodComparatorWithString`

- ## Field Summary

  ### Fields inherited from class org.codehaus.groovy.reflection.CachedClass

  `classInfo, EMPTY_ARRAY, isArray, isInterface, isNumber, isPrimitive, modifiers, mopMethods`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DoubleCachedClass(Class klazz, ClassInfo classInfo, boolean allowNull)`
  Constructs a cached class representation for the given double class.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `coerceArgument(Object argument)`
  Coerces the given numeric argument to a double value.
  `boolean`
  `isAssignableFrom(Class classToTransformFrom)`
  Determines if the given class can be transformed to double/Double.
  `boolean`
  `isDirectlyAssignable(Object argument)`
  Checks if the given argument is directly assignable without type conversion.

  ### Methods inherited from class org.codehaus.groovy.reflection.CachedClass

  `addNewMopMethods, getCachedClass, getCachedSuperClass, getConstructors, getDeclaredInterfaces, getFields, getHierarchy, getInterfaces, getMethods, getModifiers, getName, getNewMetaMethods, getSuperClassDistance, getTheClass, getTypeDescription, hashCode, isInterface, isPrimitive, isVoid, searchMethods, setNewMopMethods, toString`

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

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

- ## Constructor Details

  - ### DoubleCachedClass

    public DoubleCachedClass(Class klazz, ClassInfo classInfo, boolean allowNull)
    Constructs a cached class representation for the given double class.
    Parameters:
      `klazz` - the double class to cache (either `double.class` or `Double`.class)
      `classInfo` - the class information associated with this cached class
      `allowNull` - `true` to allow `null` values (for `Double`.class), `false` for primitive `double`

- ## Method Details

  - ### isDirectlyAssignable

    public boolean isDirectlyAssignable(Object argument)
    Checks if the given argument is directly assignable without type conversion.
    Overrides:
      `isDirectlyAssignable` in class `CachedClass`
    Parameters:
      `argument` - the argument to check
    Returns:
      `true` if the argument is a `Double` instance, or `null` is allowed, `false` otherwise

  - ### coerceArgument

    public Object coerceArgument(Object argument)
    Coerces the given numeric argument to a double value. Validates that `BigDecimal` conversions do not overflow to infinity.
    Overrides:
      `coerceArgument` in class `NumberCachedClass`
    Parameters:
      `argument` - the argument to coerce
    Returns:
      the argument as a `double`, or the original argument if not a number
    Throws:
      `IllegalArgumentException` - if a `BigDecimal` conversion results in infinity

  - ### isAssignableFrom

    public boolean isAssignableFrom(Class classToTransformFrom)
    Determines if the given class can be transformed to double/Double. Accepts all numeric types, including integral and big numeric types.
    Overrides:
      `isAssignableFrom` in class `NumberCachedClass`
    Parameters:
      `classToTransformFrom` - the source class to check
    Returns:
      `true` if the class can be transformed to double, `false` otherwise