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
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
ConstructorsConstructorDescriptionNumberCachedClass(Class klazz, ClassInfo classInfo) Constructs a cached class representation for a numeric class. -
Method Summary
Modifier and TypeMethodDescriptioncoerceArgument(Object argument) Coerces the given argument if it is aNumber.booleanisAssignableFrom(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
-
Constructor Details
-
NumberCachedClass
Constructs a cached class representation for a numeric class.- Parameters:
klazz- the numeric class to cacheclassInfo- the class information associated with this cached class
-
-
Method Details
-
coerceArgument
Coerces the given argument if it is aNumber. Delegates tocoerceNumber(java.lang.Object)for specialized conversion logic.- Overrides:
coerceArgumentin classCachedClass- Parameters:
argument- the argument to coerce- Returns:
- the coerced number or the original argument if not a
Number
-
isAssignableFrom
Determines if the given class can be transformed to this numeric type. Acceptsnull,Numbersubclasses, and primitive numeric types.- Overrides:
isAssignableFromin classCachedClass- Parameters:
classToTransformFrom- the source class to check- Returns:
trueif the class can be transformed to this numeric type,falseotherwise
-