Class PrimitiveWrapper


  • public class PrimitiveWrapper
    extends java.lang.Object
    The purpose of the Primitive Wrapper is to provide methods that deals with translating wrapper types to its related primitive type.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Map<java.lang.Class<?>,​java.lang.Class<?>> primitiveWrapper  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Class<?> getPrimitiveFromWrapperType​(java.lang.Class<?> wrapperType)
      Get the primitive counter part from a wrapped type.
      static boolean hasPrimitiveCounterPart​(java.lang.Class<?> type)
      Returns true if type has a primitive counter-part.
      static java.lang.Class<?>[] toPrimitiveType​(java.lang.Class<?>[] types)
      Convert all wrapper types in types to their primitive counter parts.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • primitiveWrapper

        private static final java.util.Map<java.lang.Class<?>,​java.lang.Class<?>> primitiveWrapper
    • Constructor Detail

      • PrimitiveWrapper

        public PrimitiveWrapper()
    • Method Detail

      • toPrimitiveType

        public static java.lang.Class<?>[] toPrimitiveType​(java.lang.Class<?>[] types)
        Convert all wrapper types in types to their primitive counter parts.
        Parameters:
        types - The array of types that should be converted.
        Returns:
        A new array where all wrapped types have been converted to their primitive counter part.
      • getPrimitiveFromWrapperType

        public static java.lang.Class<?> getPrimitiveFromWrapperType​(java.lang.Class<?> wrapperType)
        Get the primitive counter part from a wrapped type. For example:

        getPrimitiveFromWrapperType(Integer.class) will return int.class.

        Parameters:
        wrapperType - The wrapper type to convert to its primitive counter part.
        Returns:
        The primitive counter part or null if the class did not have a primitive counter part.
      • hasPrimitiveCounterPart

        public static boolean hasPrimitiveCounterPart​(java.lang.Class<?> type)
        Returns true if type has a primitive counter-part. E.g. if type if Integer then this method will return true.
        Parameters:
        type - The type to check whether or not it has a primitive counter-part.
        Returns:
        true if this type has a primitive counter-part.