Enum JavaWrapperType

java.lang.Object
java.lang.Enum<JavaWrapperType>
de.calamanari.pk.util.JavaWrapperType
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<JavaWrapperType>, java.lang.constant.Constable

public enum JavaWrapperType
extends java.lang.Enum<JavaWrapperType>
This enum contains the known java primitives and their wrapper types as an easy lookup.
Author:
Karl Eilebrecht
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    java.lang.Enum.EnumDesc<E extends java.lang.Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant Description
    BOOLEAN
    boolean vs.
    BYTE
    byte vs.
    CHARACTER
    char vs.
    DOUBLE
    double vs.
    FLOAT
    float vs.
    INTEGER
    int vs.
    LONG
    long vs.
    SHORT
    short vs.
    VOID
    void vs.
  • Field Summary

    Fields
    Modifier and Type Field Description
    boolean primitiveArraysSupported
    For symmetry reasons VOID is included, but you cannot create any primitive array of void
    This flag indicates this for generic processing.
    java.util.function.Function<java.lang.Object,​java.lang.String> primitiveArrayToStringFunction
    A function that converts any array of the given primitive type to a string
    java.lang.Class<?> primitiveType
    The primitive type that can be wrapped
    java.lang.Class<?> wrapperType
    Wrapper type for Boxing in Java
  • Method Summary

    Modifier and Type Method Description
    java.lang.String arrayToString​(java.lang.Object array)
    Provides a convenient method to print an array, no matter whether it is primitive or not.
    static JavaWrapperType forClass​(java.lang.Class<?> clazz)
    Returns the JavaWrapperType instance if the given class is either a primitive or a wrapper type.
    java.lang.String getDescription()
    For debugging (can't overwrite toString() of an enum)
    static JavaWrapperType valueOf​(java.lang.String name)
    Returns the enum constant of this type with the specified name.
    static JavaWrapperType[] values()
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Enum

    compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

  • Field Details

    • primitiveType

      public final java.lang.Class<?> primitiveType
      The primitive type that can be wrapped
    • wrapperType

      public final java.lang.Class<?> wrapperType
      Wrapper type for Boxing in Java
    • primitiveArraysSupported

      public final boolean primitiveArraysSupported
      For symmetry reasons VOID is included, but you cannot create any primitive array of void
      This flag indicates this for generic processing.
    • primitiveArrayToStringFunction

      public final java.util.function.Function<java.lang.Object,​java.lang.String> primitiveArrayToStringFunction
      A function that converts any array of the given primitive type to a string
  • Method Details

    • values

      public static JavaWrapperType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static JavaWrapperType valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
      java.lang.NullPointerException - if the argument is null
    • forClass

      public static JavaWrapperType forClass​(java.lang.Class<?> clazz)
      Returns the JavaWrapperType instance if the given class is either a primitive or a wrapper type.
      Parameters:
      clazz - primitive class or wrapper type (i.e. int.class or Integer.class)
      Returns:
      wrappable type instance or null if the given class is not supported
    • arrayToString

      public java.lang.String arrayToString​(java.lang.Object array)
      Provides a convenient method to print an array, no matter whether it is primitive or not.
      Parameters:
      array - source object, which must be an array or null (returns "null")
      Returns:
      the corresponding Arrays.toString() result for primitives arrays or any Object[]
      Throws:
      java.lang.IllegalArgumentException - if the given array's component type is neither the primitive nor the wrapper type
    • getDescription

      public java.lang.String getDescription()
      For debugging (can't overwrite toString() of an enum)
      Returns:
      description