Class PrimitiveType

java.lang.Object
org.jboss.jandex.Type
org.jboss.jandex.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
  • Field Details

  • Constructor Details

  • Method Details

    • 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
    • asPrimitiveType

      public PrimitiveType asPrimitiveType()
      Description copied from class: Type
      Casts this type to a PrimitiveType and returns it if the kind is Type.Kind.PRIMITIVE. Throws an exception otherwise.
      Overrides:
      asPrimitiveType in class Type
      Returns:
      a PrimitiveType
    • copyType

      Type copyType(AnnotationInstance[] newAnnotations)
      Specified by:
      copyType in class Type
    • toCode

      char toCode()
    • decode

      static PrimitiveType decode(String name)
    • decode

      static PrimitiveType decode(char c)
    • fromOridinal

      static PrimitiveType fromOridinal(int ordinal)
    • equals

      public boolean equals(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:
    • 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(Object o)
      Overrides:
      internEquals in class Type
    • internHashCode

      int internHashCode()
      Overrides:
      internHashCode in class Type