Package org.codehaus.groovy.reflection.stdclasses

# Class NumberCachedClass

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

Direct Known Subclasses:
  `BigIntegerCachedClass`, `ByteCachedClass`, `DoubleCachedClass`, `FloatCachedClass`, `IntegerCachedClass`, `LongCachedClass`, `ShortCachedClass`

public class NumberCachedClass extends CachedClass
Base class for optimized reflection caching of numeric types. Provides common type coercion logic for primitive and boxed numeric types, as well as `BigInteger` and `BigDecimal`.

- ## 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
  `NumberCachedClass(Class klazz, ClassInfo classInfo)`
  Constructs a cached class representation for a numeric class.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `coerceArgument(Object argument)`
  Coerces the given argument if it is a `Number`.
  `boolean`
  `isAssignableFrom(Class classToTransformFrom)`
  Determines if the given class can be transformed to this numeric type.

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

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

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

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

- ## Constructor Details

  - ### NumberCachedClass

    public NumberCachedClass(Class klazz, ClassInfo classInfo)
    Constructs a cached class representation for a numeric class.
    Parameters:
      `klazz` - the numeric class to cache
      `classInfo` - the class information associated with this cached class

- ## Method Details

  - ### coerceArgument

    public Object coerceArgument(Object argument)
    Coerces the given argument if it is a `Number`. Delegates to `coerceNumber(java.lang.Object)` for specialized conversion logic.
    Overrides:
      `coerceArgument` in class `CachedClass`
    Parameters:
      `argument` - the argument to coerce
    Returns:
      the coerced number or the original argument if not a `Number`

  - ### isAssignableFrom

    public boolean isAssignableFrom(Class classToTransformFrom)
    Determines if the given class can be transformed to this numeric type. Accepts `null`, `Number` subclasses, and primitive numeric types.
    Overrides:
      `isAssignableFrom` in class `CachedClass`
    Parameters:
      `classToTransformFrom` - the source class to check
    Returns:
      `true` if the class can be transformed to this numeric type, `false` otherwise