|
jdeparser 1.0.0.Final-redhat-1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.jdeparser.JType
org.jboss.jdeparser.JClass
public abstract class JClass
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 as JDefinedClass
.
Field Summary | |
---|---|
protected static JTypeVar[] |
EMPTY_ARRAY
Sometimes useful reusable empty array. |
Constructor Summary | |
---|---|
protected |
JClass(JDeparser _owner)
|
Method Summary | |
---|---|
abstract JClass |
_extends()
Gets the super class of this class. |
abstract Iterator<JClass> |
_implements()
Iterates all super interfaces directly implemented by this class/interface. |
abstract JPackage |
_package()
Gets the package to which this class belongs. |
JClass |
array()
Create an array type of this type. |
JClass |
boxify()
Deprecated. calling this method from JClass
would be meaningless, since it's always guaranteed to
return this. |
JExpression |
dotclass()
|
JClass |
erasure()
Returns the erasure of this type. |
void |
generate(JFormatter f)
|
JClass |
getBaseClass(Class<?> baseType)
|
JClass |
getBaseClass(JClass baseType)
Gets the parameterization of the given base type. |
JPrimitiveType |
getPrimitiveType()
If this class represents one of the wrapper classes defined in the java.lang package, return the corresponding primitive type. |
List<JClass> |
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(JClass 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. |
JClass |
narrow(Class<?>... clazz)
|
JClass |
narrow(Class<?> clazz)
"Narrows" a generic class to a concrete class by specifying a type argument. |
JClass |
narrow(JClass... clazz)
|
JClass |
narrow(JClass clazz)
"Narrows" a generic class to a concrete class by specifying a type argument. |
JClass |
narrow(JType type)
|
JClass |
narrow(List<? extends JClass> clazz)
|
JClass |
outer()
Returns the class in which this class is nested, or null if this is a top-level class. |
JDeparser |
owner()
Gets the JDeparser object to which this object belongs. |
JInvocation |
staticInvoke(JMethod method)
Generates a static method invocation. |
JInvocation |
staticInvoke(String method)
Generates a static method invocation. |
JFieldRef |
staticRef(JVar field)
Static field reference. |
JFieldRef |
staticRef(String field)
Static field reference. |
protected abstract JClass |
substituteParams(JTypeVar[] variables,
List<JClass> bindings)
Substitutes the type variables with their actual arguments. |
JClass |
superWildcard()
Create "? super T" from T |
String |
toString()
|
JTypeVar[] |
typeParams()
Iterates all the type parameters of this class/interface. |
JType |
unboxify()
If this class is a wrapper type for a primitive, return the primitive type. |
JClass |
wildcard()
Create "? extends T" from T. |
Methods inherited from class org.jboss.jdeparser.JType |
---|
binaryName, compareTo, elementType, fullName, isArray, isPrimitive, isReference, parse |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final JTypeVar[] EMPTY_ARRAY
Constructor Detail |
---|
protected JClass(JDeparser _owner)
Method Detail |
---|
public abstract String name()
name
in class JType
java.lang.String
.public abstract JPackage _package()
public JClass outer()
public final JDeparser owner()
owner
in class JType
public abstract JClass _extends()
JClass
.
Even if no super class is given explicitly or this JClass
is not a class, this method still returns
JClass
for Object
.
If this JClass represents Object
, return null.public abstract Iterator<JClass> _implements()
JClass
objects that represents those interfaces
implemented by this object.public JTypeVar[] typeParams()
For example, if this JClass
represents
Set<T>
, this method returns an array
that contains single JTypeVar
for 'T'.
public abstract boolean isInterface()
public abstract boolean isAbstract()
public JPrimitiveType getPrimitiveType()
public JClass boxify()
JClass
would be meaningless, since it's always guaranteed to
return this.
JType
For example, for "int", this method returns "java.lang.Integer".
boxify
in class JType
public JType unboxify()
JType
For example, for "java.lang.Integer", this method returns "int".
unboxify
in class JType
public JClass erasure()
JType
erasure
in class JType
public final boolean isAssignableFrom(JClass derived)
This method works in the same way as Class.isAssignableFrom(Class)
works. For example, baseClass.isAssignableFrom(derivedClass)==true.
public final JClass getBaseClass(JClass baseType)
For example, given the following
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 JClass getBaseClass(Class<?> baseType)
public JClass array()
JType
array
in class JType
JClass
representing the array type
whose element type is this typepublic JClass narrow(Class<?> clazz)
.narrow(X)
builds Set<X>
from Set
.
public JClass narrow(Class<?>... clazz)
public JClass narrow(JClass clazz)
.narrow(X)
builds Set<X>
from Set
.
public JClass narrow(JType type)
public JClass narrow(JClass... clazz)
public JClass narrow(List<? extends JClass> clazz)
public List<JClass> getTypeParameters()
public final boolean isParameterized()
public final JClass wildcard()
public final JClass superWildcard()
protected abstract JClass substituteParams(JTypeVar[] variables, List<JClass> bindings)
For example, when this class is Map<String,Map<V>>,
(where V then doing
substituteParams( V, Integer ) returns a JClass
for Map<String,Map<Integer>>
.
This method needs to work recursively.
public String toString()
toString
in class JType
public final JExpression dotclass()
public final JInvocation staticInvoke(JMethod method)
public final JInvocation staticInvoke(String method)
public final JFieldRef staticRef(String field)
public final JFieldRef staticRef(JVar field)
public void generate(JFormatter f)
|
jdeparser 1.0.0.Final-redhat-1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |