public abstract class TypeReference extends Type
GeneratedClass
.Modifier and Type | Field and Description |
---|---|
protected static TypeVariable[] |
EMPTY_ARRAY
Sometimes useful reusable empty array.
|
Modifier | Constructor and Description |
---|---|
protected |
TypeReference(CodeModel _owner) |
Modifier and Type | Method and Description |
---|---|
abstract TypeReference |
_extends()
Gets the super class of this class.
|
abstract Iterator<TypeReference> |
_implements()
Iterates all super interfaces directly implemented by
this class/interface.
|
abstract GeneratedPackage |
_package()
Gets the package to which this class belongs.
|
TypeReference |
array()
Create an array type of this type.
|
TypeReference |
array(GeneratedExpression size) |
TypeReference |
boxify()
Deprecated.
calling this method from
TypeReference
would be meaningless, since it's always guaranteed to
return this. |
TypeReference |
erasure()
Returns the erasure of this type.
|
void |
generate(Formatter f) |
TypeReference |
getBaseClass(Class<?> baseType) |
TypeReference |
getBaseClass(TypeReference baseType)
Gets the parameterization of the given base type.
|
PrimitiveType |
getPrimitiveType()
If this class represents one of the wrapper classes
defined in the java.lang package, return the corresponding
primitive type.
|
List<TypeReference> |
getTypeParameters()
If this class is parameterized, return the type parameter of the given index.
|
abstract boolean |
isAbstract()
Checks if this class is an abstract class.
|
boolean |
isAssignableFrom(TypeReference derived)
Checks the relationship between two classes.
|
abstract boolean |
isInterface()
Checks if this object represents an interface.
|
boolean |
isParameterized()
Returns true if this class is a parameterized class.
|
abstract String |
name()
Gets the name of this class.
|
TypeReference |
narrow(Class<?>... clazz) |
TypeReference |
narrow(Class<?> clazz)
"Narrows" a generic class to a concrete class by specifying
a type argument.
|
TypeReference |
narrow(List<? extends TypeReference> clazz) |
TypeReference |
narrow(String generify) |
TypeReference |
narrow(Type type) |
TypeReference |
narrow(TypeReference... clazz) |
TypeReference |
narrow(TypeReference clazz)
"Narrows" a generic class to a concrete class by specifying
a type argument.
|
TypeReference |
outer()
Returns the class in which this class is nested, or null if
this is a top-level class.
|
CodeModel |
owner()
Gets the CodeModel object to which this object belongs.
|
GeneratedInvocation |
staticInvoke(GeneratedMethod method)
Generates a static method invocation.
|
GeneratedInvocation |
staticInvoke(String method)
Generates a static method invocation.
|
GeneratedFieldReference |
staticRef(GeneratedVariable field)
Static field reference.
|
GeneratedFieldReference |
staticRef(String field)
Static field reference.
|
protected abstract TypeReference |
substituteParams(TypeVariable[] variables,
List<TypeReference> bindings)
Substitutes the type variables with their actual arguments.
|
String |
toString() |
TypeVariable[] |
typeParams()
Iterates all the type parameters of this class/interface.
|
Type |
unboxify()
If this class is a wrapper type for a primitive, return the primitive type.
|
TypeReference |
wildcard()
Create "? extends T" from T.
|
binaryName, compareTo, dotclass, elementType, equals, fullName, hashCode, isArray, isPrimitive, isReference, parse
protected static final TypeVariable[] EMPTY_ARRAY
protected TypeReference(CodeModel _owner)
public abstract String name()
public abstract GeneratedPackage _package()
public TypeReference outer()
public final CodeModel owner()
public abstract TypeReference _extends()
TypeReference
.
Even if no super class is given explicitly or this TypeReference
is not a class, this method still returns
TypeReference
for Object
.
If this TypeReference represents Object
, return null.public abstract Iterator<TypeReference> _implements()
TypeReference
objects that represents those interfaces
implemented by this object.public TypeVariable[] typeParams()
TypeReference
represents
Set<T>
, this method returns an array
that contains single TypeVariable
for 'T'.public abstract boolean isInterface()
public abstract boolean isAbstract()
public PrimitiveType getPrimitiveType()
public TypeReference boxify()
TypeReference
would be meaningless, since it's always guaranteed to
return this.Type
public Type unboxify()
Type
public TypeReference erasure()
Type
public final boolean isAssignableFrom(TypeReference derived)
Class.isAssignableFrom(Class)
works. For example, baseClass.isAssignableFrom(derivedClass)==true.public final TypeReference getBaseClass(TypeReference baseType)
This method works like this:interface Foo extends List > {} interface Bar extends Foo
{}
getBaseClass( Bar, List ) = List getBaseClass( Bar, Foo ) = Foo
getBaseClass( Foo extends Number>, Collection ) = Collection > getBaseClass( ArrayList extends BigInteger>, List ) = List extends BigInteger>
baseType
- The class whose parameterization we are interested in.baseType
in this
type.
or null if the type is not assignable to the base type.public final TypeReference getBaseClass(Class<?> baseType)
public TypeReference array()
Type
array
in class Type
TypeReference
representing the array type
whose element type is this typepublic TypeReference array(GeneratedExpression size)
public TypeReference narrow(Class<?> clazz)
.narrow(X)
builds Set<X>
from Set
.public TypeReference narrow(String generify)
public TypeReference narrow(Class<?>... clazz)
public TypeReference narrow(TypeReference clazz)
.narrow(X)
builds Set<X>
from Set
.public TypeReference narrow(Type type)
public TypeReference narrow(TypeReference... clazz)
public TypeReference narrow(List<? extends TypeReference> clazz)
public List<TypeReference> getTypeParameters()
public final boolean isParameterized()
public final TypeReference wildcard()
protected abstract TypeReference substituteParams(TypeVariable[] variables, List<TypeReference> bindings)
TypeReference
for Map<String,Map<Integer>>
.
This method needs to work recursively.public final GeneratedInvocation staticInvoke(GeneratedMethod method)
public final GeneratedInvocation staticInvoke(String method)
public final GeneratedFieldReference staticRef(String field)
public final GeneratedFieldReference staticRef(GeneratedVariable field)
public void generate(Formatter f)
Copyright © 2010–2015 MuleSoft, Inc.. All rights reserved.