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 class
PrimitiveType.Primitive
Specifies 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 PrimitiveType
BOOLEAN
private static java.util.Map<PrimitiveType.Primitive,ClassType>
boxingMap
static PrimitiveType
BYTE
static PrimitiveType
CHAR
static PrimitiveType
DOUBLE
static PrimitiveType
FLOAT
static PrimitiveType
INT
static PrimitiveType
LONG
private PrimitiveType.Primitive
primitive
private static java.util.Map<java.lang.String,PrimitiveType>
reverseMap
static PrimitiveType
SHORT
private 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 private
PrimitiveType(PrimitiveType.Primitive primitive)
private
PrimitiveType(PrimitiveType.Primitive primitive, AnnotationInstance[] annotations)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PrimitiveType
asPrimitiveType()
Casts this type to aPrimitiveType
and returns it if the kind isType.Kind.PRIMITIVE
.static ClassType
box(PrimitiveType primitiveType)
Returns a class type that is the result of a boxing conversion of the givenprimitiveType
.(package private) Type
copyType(AnnotationInstance[] newAnnotations)
(package private) static PrimitiveType
decode(char c)
(package private) static PrimitiveType
decode(java.lang.String name)
boolean
equals(java.lang.Object o)
Compares thisType
with another type.(package private) static PrimitiveType
fromOridinal(int ordinal)
int
hashCode()
Computes a hash code representing this type.(package private) boolean
internEquals(java.lang.Object o)
(package private) int
internHashCode()
Type.Kind
kind()
Returns the kind of Type this is.PrimitiveType.Primitive
primitive()
The type of primitive this primitive type represents(package private) char
toCode()
static PrimitiveType
unbox(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
-
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
null
ifprimitiveType
isnull
.- Parameters:
primitiveType
- a primitive type, may benull
- Returns:
- the corresponding class type, or
null
ifprimitiveType
isnull
-
unbox
public static PrimitiveType unbox(ClassType classType)
Returns a primitive type that is the result of an unboxing conversion of the givenclassType
.Returns
null
if no unboxing conversion exists for given class type or ifclassType
isnull
.- Parameters:
classType
- a class type, may benull
- Returns:
- the corresponding primitive type, or
null
if there's none
-
asPrimitiveType
public PrimitiveType asPrimitiveType()
Description copied from class:Type
Casts this type to aPrimitiveType
and returns it if the kind isType.Kind.PRIMITIVE
. Throws an exception otherwise.- Overrides:
asPrimitiveType
in 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:Type
Compares thisType
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.
-
hashCode
public int hashCode()
Description copied from class:Type
Computes a hash code representing this type.
-
internEquals
boolean internEquals(java.lang.Object o)
- Overrides:
internEquals
in classType
-
internHashCode
int internHashCode()
- Overrides:
internHashCode
in classType
-
-