public abstract class AbstractJType extends Object implements IJGenerable, IJOwned
JPrimitiveType
) or a reference type (AbstractJClass
).Comparable <AbstractJType>
. Since this was specific to
import handling on emitting code, it was removed with 2.7.7!Constructor and Description |
---|
AbstractJType() |
Modifier and Type | Method and Description |
---|---|
abstract JArrayClass |
array()
Create an array type of this type.
|
String |
binaryName()
Gets the binary name of the type.
|
abstract AbstractJClass |
boxify()
If this class is a primitive type, return the boxed class.
|
boolean |
containsTypeVar(JTypeVar aVar)
Check if this class is a generic class and contains the passed type
variable.
|
AbstractJType |
declarable() |
AbstractJType |
elementType()
If this is an array, returns the component type of the array (T of T[]).
|
AbstractJType |
erasure() |
abstract String |
fullName()
Gets the full name of the type.
|
boolean |
isArray()
Tell whether or not this is an array type.
|
boolean |
isAssignableFrom(AbstractJType that)
Checks the relationship between two types.
|
protected boolean |
isAssignableFrom(AbstractJType that,
boolean bAllowsRawTypeUnchekedConversion) |
boolean |
isError()
Tells whether or not this is an error-type.
|
boolean |
isPrimitive()
Tell whether or not this is a built-in primitive type, such as int or void.
|
boolean |
isReference() |
abstract String |
name()
Gets the name of this type.
|
static JPrimitiveType |
parse(JCodeModel codeModel,
String sTypeName)
Obtains a reference to the primitive type object from a type name.
|
String |
toString() |
abstract AbstractJType |
unboxify()
If this class is a wrapper type for a primitive, return the primitive type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
generate
@Nonnull public static JPrimitiveType parse(@Nonnull JCodeModel codeModel, @Nonnull String sTypeName)
codeModel
- Base code modelsTypeName
- primitive type to be parsed (e.g. "int" or "void")null
IllegalArgumentException
- If the passed type name is not a primitive type name@Nullable public abstract String fullName()
null
for unnamed classes.@Nonnull public String binaryName()
@Nonnull public abstract String name()
public abstract JArrayClass array()
JArrayClass
representing the array type whose element
type is this typepublic boolean isArray()
true
if this an array typepublic boolean isPrimitive()
true
if this is a primitive typepublic boolean isError()
Error types are not actual Java types and shouldn't be used in actually generated code.
true
if this is an error classJErrorClass
@Nonnull public abstract AbstractJClass boxify()
For example, for "int", this method returns "java.lang.Integer".
null
@Nonnull public abstract AbstractJType unboxify()
For example, for "java.lang.Integer", this method returns "int".
null
@Nonnull public AbstractJType erasure()
List<Integer>
in which case this
method returns the reference to List
without any
generic type parameters.@Nonnull public AbstractJType declarable()
public final boolean isReference()
true
if this is a referenced type (which means it is
not a primitive type).@Nonnull public AbstractJType elementType()
isArray()
).null
.IllegalArgumentException
- If this is not an array typepublic boolean containsTypeVar(@Nullable JTypeVar aVar)
aVar
- The type variable to check. May be null
.true
if the passed type variable is contained,
false
otherwise.public boolean isAssignableFrom(@Nonnull AbstractJType that)
This method performs superset of actions that are performed by
Class.isAssignableFrom(Class)
For example,
baseClass.isAssignableFrom(derivedClass) is always true
.
There are two differences of this method and
Class.isAssignableFrom(Class)
Examples:
that
- Type to checktrue
if assignable, false
if notprotected boolean isAssignableFrom(@Nonnull AbstractJType that, boolean bAllowsRawTypeUnchekedConversion)
Copyright © 2013–2017 Philip Helger. All rights reserved.