Class Autoboxers


  • public class Autoboxers
    extends Object

    Class containing utility functionality for reflection based programming with primitive and boxing types

    Since:
    2.0
    Author:
    Christoph Praschl
    • Constructor Detail

      • Autoboxers

        public Autoboxers()
    • Method Detail

      • getBoxingClasses

        public static Map<Class<?>,​Class<?>> getBoxingClasses()
        Returns:
        a map of boxing classes (key) with the corresponding primitive classes (value)
      • getPrimitiveDefaultValues

        public static Map<Class<?>,​Object> getPrimitiveDefaultValues()
        Returns:
        the default values of boxing classes
      • getPrimitiveDefaultValue

        public static <T> T getPrimitiveDefaultValue​(Class<T> clazz)
        Type Parameters:
        T - type parameter
        Parameters:
        clazz - for which default value is needed
        Returns:
        default value of the given class or NULL if given clazz is not primitive
      • getPrimitiveClasses

        public static Map<Class<?>,​Class<?>> getPrimitiveClasses()
        Returns:
        a map of primitive classes (key) with the corresponding boxing classes (value)
      • isBoxingClass

        public static boolean isBoxingClass​(Class<?> clazz)
        Checks if given clazz is a boxing clazz
        Parameters:
        clazz - clazz to check
        Returns:
        true if clazz is a boxing class else false
      • isPrimitiveClass

        public static boolean isPrimitiveClass​(Class<?> clazz)
        Checks if given clazz is a primitive clazz
        Parameters:
        clazz - clazz to check
        Returns:
        true if clazz is a primitive class else false
      • isPrimitiveOrBoxingClass

        public static boolean isPrimitiveOrBoxingClass​(Class<?> clazz)
        Checks if given clazz is a primitive clazz or a boxing clazz
        Parameters:
        clazz - clazz to check
        Returns:
        true if clazz is a primitive or a boxing class else false
      • getBoxingClass

        public static Class<?> getBoxingClass​(Class<?> primitiveClass)
        Returns the associated boxing type for a given primitive class
        Parameters:
        primitiveClass - for which boxing type is required
        Returns:
        boxing type
        Throws:
        IllegalArgumentException - if given class is not a primitive type
      • getPrimitiveClass

        public static Class<?> getPrimitiveClass​(Class<?> boxingClass)
        Returns the associated primitive type for a given boxing class
        Parameters:
        boxingClass - for which primitive type is required
        Returns:
        primitive type
        Throws:
        IllegalArgumentException - if given class is not a boxing type