Class FloatCachedClass


public class FloatCachedClass extends NumberCachedClass
Provides optimized reflection caching for float and Float. Coerces numeric arguments to float values, with validation to prevent overflow to infinity. Optionally allows null values for the boxed Float class variant.
  • Constructor Details

    • FloatCachedClass

      public FloatCachedClass(Class klazz, ClassInfo classInfo, boolean allowNull)
      Constructs a cached class representation for the given float class.
      Parameters:
      klazz - the float class to cache (either float.class or Float.class)
      classInfo - the class information associated with this cached class
      allowNull - true to allow null values (for Float.class), false for primitive float
  • Method Details

    • coerceArgument

      public Object coerceArgument(Object argument)
      Coerces the given numeric argument to a float 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 float, or the original argument if not a number
      Throws:
      IllegalArgumentException - if a BigDecimal conversion results in infinity
    • 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 Float instance, or null is allowed, false otherwise
    • isAssignableFrom

      public boolean isAssignableFrom(Class classToTransformFrom)
      Determines if the given class can be transformed to float/Float. Accepts 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 float, false otherwise