|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mule.devkit.model.code.Type
org.mule.devkit.model.code.TypeReference
public abstract class TypeReference
Represents a Java reference type, such as a class, an interface, an enum, an array type, a parameterized type.
To be exact, this object represents an "use" of a reference type, not necessarily a declaration of it, which is modeled asGeneratedClass.
| Field Summary | |
|---|---|
protected static TypeVariable[] |
EMPTY_ARRAY
Sometimes useful reusable empty array. |
| Constructor Summary | |
|---|---|
protected |
TypeReference(CodeModel _owner)
|
| Method Summary | |
|---|---|
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(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. |
| Methods inherited from class org.mule.devkit.model.code.Type |
|---|
binaryName, compareTo, dotclass, elementType, equals, fullName, hashCode, isArray, isPrimitive, isReference, parse |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final TypeVariable[] EMPTY_ARRAY
| Constructor Detail |
|---|
protected TypeReference(CodeModel _owner)
| Method Detail |
|---|
public abstract String name()
name in class Typejava.lang.String.public abstract GeneratedPackage _package()
public TypeReference outer()
public final CodeModel owner()
owner in class Typepublic 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
boxify in class Typepublic Type unboxify()
Type
unboxify in class Typepublic TypeReference erasure()
Type
erasure in class Typepublic 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 TypeTypeReference 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(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 String toString()
toString in class Typepublic 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)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||