public class PrimitiveType extends Type
| Modifier and Type | Field and Description |
|---|---|
private static java.util.Map<java.lang.Class<?>,PrimitiveType> |
cache
All the PrimitiveTypes that have been created.
|
private java.lang.Class<?> |
runtimeClass
The runtime class of the primitive type.
|
| Modifier | Constructor and Description |
|---|---|
private |
PrimitiveType(java.lang.Class<?> runtimeClass)
Creates a primitive type from the given runtime class.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(@Nullable java.lang.Object obj) |
static PrimitiveType |
forClass(java.lang.Class<?> runtimeClass)
Creates a primitive type from the given runtime class.
|
java.lang.String |
getBinaryName()
Returns the binary name of this type, including type arguments if this is a parameterized type
(so, it isn't really a binary name).
|
@Nullable java.lang.String |
getFqName()
Returns the fully-qualified name of this type, including type arguments if this is a
parameterized type.
|
java.lang.Class<?> |
getRuntimeClass()
Returns the runtime
Class object for this type. |
java.lang.String |
getSimpleName()
Returns the name of this type without type arguments or package qualifiers.
|
int |
hashCode() |
boolean |
isAssignableFrom(Type sourceType)
Indicates whether there is an assignment conversion from a source
Type to this type. |
boolean |
isNonreceiverType()
Indicates whether this is the type of a non-receiver term: primitive, boxed primitive,
String, or Class. |
boolean |
isPrimitive()
Indicates whether this is a primitive type.
|
boolean |
isSubtypeOf(Type otherType)
Test whether this type is a subtype of the given type according to transitive closure of
definition of the direct supertype relation in section 4.10 of
JLS for Java SE 8.
|
NonParameterizedType |
toBoxedPrimitive()
Returns the boxed type for this primitive type.
|
applyCaptureConversion, compareTo, forFullyQualifiedName, forName, forType, forValue, getCanonicalName, getRawtype, getTypeforFullyQualifiedName, getUnqualifiedBinaryName, hasCaptureVariable, hasWildcard, isArray, isAssignableFromTypeOf, isBoxedPrimitive, isClass, isClassOrInterfaceType, isEnum, isGeneric, isGeneric, isInterface, isObject, isParameterized, isRawtype, isReferenceType, isString, isVariable, isVoid, runtimeClassIs, substitute, toStringprivate final java.lang.Class<?> runtimeClass
private static java.util.Map<java.lang.Class<?>,PrimitiveType> cache
private PrimitiveType(java.lang.Class<?> runtimeClass)
runtimeClass - the runtime classpublic static PrimitiveType forClass(java.lang.Class<?> runtimeClass)
runtimeClass - the runtime classpublic boolean equals(@Nullable java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic @Nullable java.lang.String getFqName()
Typejava.util.List<T> return "java.util.List<T>".public java.lang.String getBinaryName()
Typejava.util.List<T> return "java.util.List<T>".getBinaryName in class Typepublic java.lang.String getSimpleName()
Typejava.util.List<T>, returns "List".getSimpleName in class Typepublic java.lang.Class<?> getRuntimeClass()
Class object for this type. For use when reflection is needed.
Note that type variables and the null reference type do not have a runtime class, and this method will return null in those cases.
This method should not be confused with the inherited Object.getClass() method,
which returns the Class<?> for the Type object, and not of the represented
type. For instance, if a Type object t represented the Java type int,
then t.getRuntimeClass() would return int.class while t.getClass()
would return Type.class.
getRuntimeClass in class TypeClass object for this primitive typepublic boolean isAssignableFrom(Type sourceType)
Type to this type.
(In other words, a value of the source type can be assigned to an l-value of this type.)
Returns true if this is a legal assignment conversion:
Variablethis = Expressionsourcetype.
Based on the definition of assignment context in section 5.2 of the Java Language Specification, a value of one type is assignable to a variable of another type if the first type can be converted to the second by
Checks for primitive widening (section 5.1.2), and unboxing (section 5.1.8) conversions. For a primitive type, returns true if this type can be assigned from the source type by primitive widening or unboxing.
isAssignableFrom in class TypesourceType - the type to test for assignabilitypublic boolean isPrimitive()
isPrimitive in class Typepublic boolean isNonreceiverType()
String, or Class.isNonreceiverType in class Typepublic boolean isSubtypeOf(Type otherType)
Specifically implements tests for primitive types as defined in section 4.10.1 of JLS for JavaSE 8.
isSubtypeOf in class TypeotherType - the possible supertypepublic NonParameterizedType toBoxedPrimitive()