Class PrimitiveType

  • All Implemented Interfaces:
    Descriptor

    public final class PrimitiveType
    extends Type
    Represents a primitive Java type. While a set of constants is provided for easy of use, instance equality should not be used to compare to them. Instead equals(Object) should be used.

    A primitive is considered equal to another primitive if it specifies the same primitive enumeration value, and contains an equal set of annotation instances.

    Since:
    2.0
    • Method Detail

      • kind

        public Type.Kind kind()
        Description copied from class: Type
        Returns the kind of Type this is.
        Specified by:
        kind in class Type
        Returns:
        the kind
      • primitive

        public PrimitiveType.Primitive primitive()
        The type of primitive this primitive type represents
        Returns:
        the primitive
      • box

        public static ClassType box​(PrimitiveType primitiveType)
        Returns a class type that is the result of a boxing conversion of the given primitiveType.

        Returns null if primitiveType is null.

        Parameters:
        primitiveType - a primitive type, may be null
        Returns:
        the corresponding class type, or null if primitiveType is null
      • unbox

        public static PrimitiveType unbox​(ClassType classType)
        Returns a primitive type that is the result of an unboxing conversion of the given classType.

        Returns null if no unboxing conversion exists for given class type or if classType is null.

        Parameters:
        classType - a class type, may be null
        Returns:
        the corresponding primitive type, or null if there's none
      • toCode

        char toCode()
      • decode

        static PrimitiveType decode​(java.lang.String name)
      • fromOridinal

        static PrimitiveType fromOridinal​(int ordinal)
      • equals

        public boolean equals​(java.lang.Object o)
        Description copied from class: Type
        Compares this Type with another type. A type is equal to another type if it is of the same kind, and all of their fields are equal. This includes annotations, which must be equal as well.
        Overrides:
        equals in class Type
        Parameters:
        o - the type to compare to
        Returns:
        true if equal
        See Also:
        Object.equals(Object)
      • hashCode

        public int hashCode()
        Description copied from class: Type
        Computes a hash code representing this type.
        Overrides:
        hashCode in class Type
        Returns:
        the hash code
      • internEquals

        boolean internEquals​(java.lang.Object o)
        Overrides:
        internEquals in class Type