public abstract class AbstractJClass extends AbstractJType
To be exact, this object represents an "use" of a reference type, not
necessarily a declaration of it, which is modeled as JDefinedClass.
| Modifier and Type | Field and Description |
|---|---|
static JTypeVar[] |
EMPTY_ARRAY
Sometimes useful reusable empty array.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractJClass(JCodeModel aOwner) |
| Modifier and Type | Method and Description |
|---|---|
abstract AbstractJClass |
_extends()
Gets the super class of this class.
|
abstract Iterator<AbstractJClass> |
_implements()
Iterates all super interfaces directly implemented by this class/interface.
|
abstract JPackage |
_package()
Gets the package to which this class belongs.
|
JArrayClass |
array()
Create an array type of this type.
|
AbstractJClass |
boxify()
Deprecated.
calling this method from
AbstractJClass would be
meaningless, since it's always guaranteed to return
this. |
IJExpression |
dotclass() |
AbstractJClass |
erasure() |
void |
generate(JFormatter f) |
AbstractJClass |
getBaseClass(AbstractJClass baseType)
Gets the parameterization of the given base type.
|
AbstractJClass |
getBaseClass(Class<?> baseType) |
JPrimitiveType |
getPrimitiveType() |
List<? extends AbstractJClass> |
getTypeParameters() |
abstract boolean |
isAbstract() |
abstract boolean |
isInterface() |
boolean |
isParameterized() |
abstract String |
name()
Gets the name of this class.
|
AbstractJClass |
narrow(AbstractJClass... clazz) |
JNarrowedClass |
narrow(AbstractJClass clazz)
"Narrows" a generic class to a concrete class by specifying a type
argument.
|
JNarrowedClass |
narrow(AbstractJType type) |
AbstractJClass |
narrow(Class<?>... clazz) |
JNarrowedClass |
narrow(Class<?> clazz)
"Narrows" a generic class to a concrete class by specifying a type
argument.
|
AbstractJClass |
narrow(List<? extends AbstractJClass> clazz) |
AbstractJClass |
outer() |
JCodeModel |
owner()
Gets the owner code model object.
|
JInvocation |
staticInvoke(JMethod aMethod)
Generates a static method invocation.
|
JInvocation |
staticInvoke(String sMethod)
Generates a static method invocation.
|
JFieldRef |
staticRef(JVar aField)
Static field reference.
|
JFieldRef |
staticRef(String sField)
Static field reference.
|
protected abstract AbstractJClass |
substituteParams(JTypeVar[] variables,
List<? extends AbstractJClass> bindings)
Substitutes the type variables with their actual arguments.
|
String |
toString() |
JTypeVar[] |
typeParams()
Iterates all the type parameters of this class/interface.
|
AbstractJType |
unboxify()
If this class is a wrapper type for a primitive, return the primitive type.
|
JTypeWildcard |
wildcard()
Create "?
|
JTypeWildcard |
wildcard(JTypeWildcard.EBoundMode eMode)
Create "?
|
JTypeWildcard |
wildcardSuper()
Create "?
|
binaryName, elementType, fullName, isArray, isAssignableFrom, isAssignableFrom, isError, isPrimitive, isReference, parsepublic static final JTypeVar[] EMPTY_ARRAY
protected AbstractJClass(@Nonnull JCodeModel aOwner)
public abstract String name()
name in class AbstractJTypejava.lang.String.public abstract JPackage _package()
JPackage this class belongs to. Is usually not
null except for the JTypeVar and the
JTypeWildcard implementation.@Nullable public AbstractJClass outer()
@Nonnull public final JCodeModel owner()
IJOwnednull.@Nullable public abstract AbstractJClass _extends()
AbstractJClass representing the superclass of
the entity (class or interface) represented by this
AbstractJClass. Even if no super class is given explicitly
or this AbstractJClass is not a class, this method still
returns AbstractJClass for Object. If this
AbstractJClass represents Object, return null.@Nonnull public abstract Iterator<AbstractJClass> _implements()
AbstractJClass
objects that represents those interfaces implemented by this
object.public abstract boolean isInterface()
true if this object represents an interface.public abstract boolean isAbstract()
true if this class is an abstract class.@Nullable public JPrimitiveType getPrimitiveType()
java.lang package, return the corresponding primitive
type. Otherwise null.@Deprecated public AbstractJClass boxify()
AbstractJClass would be
meaningless, since it's always guaranteed to return
this.AbstractJTypeFor example, for "int", this method returns "java.lang.Integer".
boxify in class AbstractJTypenull@Nonnull public AbstractJType unboxify()
AbstractJTypeFor example, for "java.lang.Integer", this method returns "int".
unboxify in class AbstractJTypenull@Nonnull public AbstractJClass erasure()
erasure in class AbstractJTypeList<Integer> in which case this
method returns the reference to List without any
generic type parameters.@Nullable public final AbstractJClass getBaseClass(@Nonnull AbstractJClass baseType)
For example, given the following
interface Foo<T> extends List<List<T>> {}
interface Bar extends Foo<String> {}
This method works like this:
getBaseClass( Bar, List ) = List<List<String>
getBaseClass( Bar, Foo ) = Foo<String>
getBaseClass( Foo<? extends Number>, Collection ) = Collection<List<? extends Number>>
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.@Nullable public final AbstractJClass getBaseClass(@Nonnull Class<?> baseType)
@Nonnull public JArrayClass array()
AbstractJTypearray in class AbstractJTypeJArrayClass representing the array type whose element
type is this type@Nonnull public JNarrowedClass narrow(@Nonnull Class<?> clazz)
.narrow(X) builds Set<X> from
Set.clazz - class to narrow withnull. Narrowed class.@Nonnull public AbstractJClass narrow(@Nonnull Class<?>... clazz)
@Nonnull public JNarrowedClass narrow(AbstractJClass clazz)
.narrow(X) builds Set<X> from
Set.clazz - class to narrow withnull. Narrowed class.@Nonnull public JNarrowedClass narrow(@Nonnull AbstractJType type)
@Nonnull public AbstractJClass narrow(@Nonnull AbstractJClass... clazz)
@Nonnull public AbstractJClass narrow(@Nonnull List<? extends AbstractJClass> clazz)
@Nonnull public List<? extends AbstractJClass> getTypeParameters()
@Nonnull public JTypeVar[] typeParams()
AbstractJClass represents
Set<T>, this method returns an array that contains
single JTypeVar for 'T'.public final boolean isParameterized()
true if this class is a parameterized class.@Nonnull public final JTypeWildcard wildcard()
null@Nonnull public final JTypeWildcard wildcardSuper()
null@Nonnull public final JTypeWildcard wildcard(@Nonnull JTypeWildcard.EBoundMode eMode)
eMode - "extends" or "super"null@Nonnull protected abstract AbstractJClass substituteParams(@Nonnull JTypeVar[] variables, @Nonnull List<? extends AbstractJClass> bindings)
AbstractJClass
for Map<String,Map<Integer>>. variables - Type variablesbindings - Bindingsnull.@Nonnull public final IJExpression dotclass()
.class@Nonnull public final JInvocation staticInvoke(@Nonnull JMethod aMethod)
aMethod - Method to be invokedJInvocation@Nonnull public final JInvocation staticInvoke(@Nonnull String sMethod)
sMethod - Method to be invokedJInvocation@Nonnull public final JFieldRef staticRef(String sField)
sField - Field to be referencedJFieldRef@Nonnull public final JFieldRef staticRef(JVar aField)
aField - Field to be referencedJFieldRefpublic void generate(@Nonnull JFormatter f)
public String toString()
toString in class AbstractJTypeCopyright © 2013–2015 Philip Helger. All rights reserved.