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.
  • 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