Package org.jboss.jandex
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. Insteadequals(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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPrimitiveType.PrimitiveSpecifies the underlying Java primitive type for aPrimitiveType-
Nested classes/interfaces inherited from class org.jboss.jandex.Type
Type.Builder<THIS extends Type.Builder<THIS>>, Type.Kind
-
-
Field Summary
Fields Modifier and Type Field Description static PrimitiveTypeBOOLEANprivate static java.util.Map<PrimitiveType.Primitive,ClassType>boxingMapstatic PrimitiveTypeBYTEstatic PrimitiveTypeCHARstatic PrimitiveTypeDOUBLEstatic PrimitiveTypeFLOATstatic PrimitiveTypeINTstatic PrimitiveTypeLONGprivate PrimitiveType.Primitiveprimitiveprivate static java.util.Map<java.lang.String,PrimitiveType>reverseMapstatic PrimitiveTypeSHORTprivate static java.util.Map<DotName,PrimitiveType>unboxingMap-
Fields inherited from class org.jboss.jandex.Type
EMPTY_ARRAY
-
Fields inherited from interface org.jboss.jandex.Descriptor
NO_SUBSTITUTION
-
-
Constructor Summary
Constructors Modifier Constructor Description privatePrimitiveType(PrimitiveType.Primitive primitive)privatePrimitiveType(PrimitiveType.Primitive primitive, AnnotationInstance[] annotations)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PrimitiveTypeasPrimitiveType()Casts this type to aPrimitiveTypeand returns it if the kind isType.Kind.PRIMITIVE.static ClassTypebox(PrimitiveType primitiveType)Returns a class type that is the result of a boxing conversion of the givenprimitiveType.(package private) TypecopyType(AnnotationInstance[] newAnnotations)(package private) static PrimitiveTypedecode(char c)(package private) static PrimitiveTypedecode(java.lang.String name)booleanequals(java.lang.Object o)Compares thisTypewith another type.(package private) static PrimitiveTypefromOridinal(int ordinal)inthashCode()Computes a hash code representing this type.(package private) booleaninternEquals(java.lang.Object o)(package private) intinternHashCode()static booleanisBox(Type type)Returns whether the giventypeis a wrapper class for any primitive type (or, in other words, whether thetypemay be a result of a boxing conversion of any primitive type.)Type.Kindkind()Returns the kind of Type this is.PrimitiveType.Primitiveprimitive()The type of primitive this primitive type represents(package private) chartoCode()static PrimitiveTypeunbox(ClassType classType)Returns a primitive type that is the result of an unboxing conversion of the givenclassType.-
Methods inherited from class org.jboss.jandex.Type
addAnnotation, annotation, annotationArray, annotations, annotationsWithRepeatable, appendAnnotations, asArrayType, asClassType, asParameterizedType, asTypeVariable, asTypeVariableReference, asUnresolvedTypeVariable, asVoidType, asWildcardType, create, create, createWithAnnotations, descriptor, hasAnnotation, name, parse, toString, toString, withoutAnnotations
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jboss.jandex.Descriptor
descriptor
-
-
-
-
Field Detail
-
BYTE
public static final PrimitiveType BYTE
-
CHAR
public static final PrimitiveType CHAR
-
DOUBLE
public static final PrimitiveType DOUBLE
-
FLOAT
public static final PrimitiveType FLOAT
-
INT
public static final PrimitiveType INT
-
LONG
public static final PrimitiveType LONG
-
SHORT
public static final PrimitiveType SHORT
-
BOOLEAN
public static final PrimitiveType BOOLEAN
-
reverseMap
private static final java.util.Map<java.lang.String,PrimitiveType> reverseMap
-
boxingMap
private static final java.util.Map<PrimitiveType.Primitive,ClassType> boxingMap
-
unboxingMap
private static final java.util.Map<DotName,PrimitiveType> unboxingMap
-
primitive
private final PrimitiveType.Primitive primitive
-
-
Constructor Detail
-
PrimitiveType
private PrimitiveType(PrimitiveType.Primitive primitive)
-
PrimitiveType
private PrimitiveType(PrimitiveType.Primitive primitive, AnnotationInstance[] annotations)
-
-
Method Detail
-
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 givenprimitiveType.Returns
nullifprimitiveTypeisnull.- Parameters:
primitiveType- a primitive type, may benull- Returns:
- the corresponding class type, or
nullifprimitiveTypeisnull
-
isBox
public static boolean isBox(Type type)
Returns whether the giventypeis a wrapper class for any primitive type (or, in other words, whether thetypemay be a result of a boxing conversion of any primitive type.)Returns
falseiftypeis not aType.Kind.CLASSor whentypeisnull.- Parameters:
type- the type to check, may benull- Returns:
- whether the given
typeis a wrapper class for a primitive type
-
unbox
public static PrimitiveType unbox(ClassType classType)
Returns a primitive type that is the result of an unboxing conversion of the givenclassType.Returns
nullif no unboxing conversion exists for given class type or ifclassTypeisnull.- Parameters:
classType- a class type, may benull- Returns:
- the corresponding primitive type, or
nullif there's none
-
asPrimitiveType
public PrimitiveType asPrimitiveType()
Description copied from class:TypeCasts this type to aPrimitiveTypeand returns it if the kind isType.Kind.PRIMITIVE. Throws an exception otherwise.- Overrides:
asPrimitiveTypein classType- Returns:
- a
PrimitiveType
-
copyType
Type copyType(AnnotationInstance[] newAnnotations)
-
toCode
char toCode()
-
decode
static PrimitiveType decode(java.lang.String name)
-
decode
static PrimitiveType decode(char c)
-
fromOridinal
static PrimitiveType fromOridinal(int ordinal)
-
equals
public boolean equals(java.lang.Object o)
Description copied from class:TypeCompares thisTypewith 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.
-
hashCode
public int hashCode()
Description copied from class:TypeComputes a hash code representing this type.
-
internEquals
boolean internEquals(java.lang.Object o)
- Overrides:
internEqualsin classType
-
internHashCode
int internHashCode()
- Overrides:
internHashCodein classType
-
-