Enum Primitive

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Primitive>

    public enum Primitive
    extends java.lang.Enum<Primitive>
    Enumerates the Java primitive types
    Since:
    19.3.0
    Author:
    cdivilly
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      BOOLEAN
      The boolean type
      BYTE
      The byte type
      CHAR
      The char type
      DOUBLE
      The double type
      FLOAT
      The float type
      INT
      The int type
      LONG
      The long type
      REFERENCE
      A reference to a non primitive type
      SHORT
      The short type
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean booleanValue​(java.lang.Object value)
      Convert an object instance to a boolean value
      byte byteValue​(java.lang.Object value)
      Convert an object instance to a byte value
      char charValue​(java.lang.Object value)
      Convert an object instance to a char value
      double doubleValue​(java.lang.Object value)
      Convert an object instance to a double value
      float floatValue​(java.lang.Object value)
      Convert an object instance to a float value
      int intValue​(java.lang.Object value)
      Convert an object instance to an int value
      boolean isPrimitive()
      Indicates if this value represents a primitive type.
      long longValue​(java.lang.Object value)
      Convert an object instance to a long value
      short shortValue​(java.lang.Object value)
      Convert an object instance to a short value
      java.lang.Class<?> type()
      This primtiive type's Class instance
      static Primitive valueOf​(java.lang.Class<?> type)
      Determine the appropriate Primitive instance for the specified type
      static Primitive valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static Primitive[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      PrimitiveWrapper wrapper()
      Retrieves the equivalent wrapper type for this primitive type
      java.lang.Class<?> wrapperType()
      The wrapper type associated with this type.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

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

      • BOOLEAN

        public static final Primitive BOOLEAN
        The boolean type
      • BYTE

        public static final Primitive BYTE
        The byte type
      • CHAR

        public static final Primitive CHAR
        The char type
      • DOUBLE

        public static final Primitive DOUBLE
        The double type
      • FLOAT

        public static final Primitive FLOAT
        The float type
      • INT

        public static final Primitive INT
        The int type
      • LONG

        public static final Primitive LONG
        The long type
      • REFERENCE

        public static final Primitive REFERENCE
        A reference to a non primitive type
      • SHORT

        public static final Primitive SHORT
        The short type
    • Method Detail

      • values

        public static Primitive[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Primitive c : Primitive.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Primitive 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
      • booleanValue

        public boolean booleanValue​(java.lang.Object value)
        Convert an object instance to a boolean value
        Parameters:
        value - The value to cast
        Returns:
        The boolean representation
      • byteValue

        public byte byteValue​(java.lang.Object value)
        Convert an object instance to a byte value
        Parameters:
        value - The value to cast
        Returns:
        The byte representation
      • charValue

        public char charValue​(java.lang.Object value)
        Convert an object instance to a char value
        Parameters:
        value - The value to cast
        Returns:
        The char representation
      • doubleValue

        public double doubleValue​(java.lang.Object value)
        Convert an object instance to a double value
        Parameters:
        value - The value to cast
        Returns:
        The double representation
      • floatValue

        public float floatValue​(java.lang.Object value)
        Convert an object instance to a float value
        Parameters:
        value - The value to cast
        Returns:
        The float representation
      • intValue

        public int intValue​(java.lang.Object value)
        Convert an object instance to an int value
        Parameters:
        value - The value to cast
        Returns:
        The int representation
      • isPrimitive

        public final boolean isPrimitive()
        Indicates if this value represents a primitive type.
        Returns:
        false if this is an instance of REFERENCE, true otherwise
      • longValue

        public long longValue​(java.lang.Object value)
        Convert an object instance to a long value
        Parameters:
        value - The value to cast
        Returns:
        The long representation
      • shortValue

        public short shortValue​(java.lang.Object value)
        Convert an object instance to a short value
        Parameters:
        value - The value to cast
        Returns:
        The short representation
      • wrapperType

        public java.lang.Class<?> wrapperType()
        The wrapper type associated with this type. For example the wrapper type for int is Integer
        Returns:
        The wrapper type for this primitive type
      • type

        public java.lang.Class<?> type()
        This primtiive type's Class instance
        Returns:
        Class instance
      • valueOf

        public static Primitive valueOf​(java.lang.Class<?> type)
        Determine the appropriate Primitive instance for the specified type
        Parameters:
        type - The type to examine
        Returns:
        The corresponding Primitive instance