public class VoidType extends Type
void. Technically, void is used to indicate that a method has no
return values, and is not a type. However, we need to pretend that it is to be able to represent
typed operations.
The decision to have void be a separate "type" is counter to the fact that the
reflection method Class.isPrimitive() returns true for void.
| Modifier | Constructor and Description |
|---|---|
private |
VoidType() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(@Nullable java.lang.Object obj) |
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).
|
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.
|
static VoidType |
getVoidType() |
int |
hashCode() |
boolean |
isAssignableFrom(Type sourceType)
Indicates whether there is an assignment conversion from a source
Type to this 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.
|
boolean |
isVoid()
Indicate whether this type is void.
|
applyCaptureConversion, compareTo, forClass, forFullyQualifiedName, forName, forType, forValue, getCanonicalName, getRawtype, getTypeforFullyQualifiedName, getUnqualifiedBinaryName, hasCaptureVariable, hasWildcard, isArray, isAssignableFromTypeOf, isBoxedPrimitive, isClass, isClassOrInterfaceType, isEnum, isGeneric, isGeneric, isInterface, isNonreceiverType, isObject, isParameterized, isPrimitive, isRawtype, isReferenceType, isString, isVariable, runtimeClassIs, substitute, toStringprivate static final VoidType value
public static VoidType getVoidType()
public boolean equals(@Nullable java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.Class<?> getRuntimeClass()
TypeClass 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 that is the runtime representation of the type, or null if this type
is a type variable or null reference typepublic 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 boolean isVoid()
Typepublic boolean isSubtypeOf(Type otherType)
Returns false, since void is not a subtype of any type
isSubtypeOf in class TypeotherType - the possible supertypepublic 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
Return false because cannot assign to void.
isAssignableFrom in class TypesourceType - the type to test for assignability