Package com.google.gwt.core.ext.typeinfo
Interface JClassType
- All Superinterfaces:
HasAnnotations
,JType
- All Known Subinterfaces:
JAnnotationType
,JArrayType
,JEnumType
,JGenericType
,JParameterizedType
,JRawType
,JRealClassType
,JTypeParameter
,JWildcardType
Type used to represent any non-primitive type.
-
Method Summary
Modifier and TypeMethodDescription<T extends Annotation>
TfindAnnotationInTypeHierarchy
(Class<T> annotationType) Find an annotation on a type or on one of its superclasses or superinterfaces.findConstructor
(JType[] paramTypes) Returns the constructor with parameters that have the given types, or null if not found.findMethod
(String name, JType[] paramTypes) findNestedType
(String typeName) getConstructor
(JType[] paramTypes) Returns the enclosing type, or null if none.Returns this type with no type parameters or type variables.JField[]
Set
<? extends JClassType> Returns all of the superclasses and superinterfaces for a given type including the type itself.JMethod[]
Iterates over the most-derived declaration of each unique inheritable method available in the type hierarchy of the specified type, including those found in superclasses and superinterfaces.JMethod[]
Returns the declared methods of this class (not any superclasses or superinterfaces).getName()
If an array, returns the name of this class without the package name or enclosing class name, followed by multiple pairs of square brackets; if not, returns the nested name of this type (like Foo or Foo.Bar), without the package name.getNestedType
(String typeName) JMethod[]
getOverloads
(String name) Returns the declared methods of this class with the given name (doesn't include any superclasses or superinterfaces).JMethod[]
Iterates over the most-derived declaration of each unique overridable method available in the type hierarchy of the specified type, including those found in superclasses and superinterfaces.Returns all subtypes of this type, recursively, not including this type.Returns the superclass of this type, ornull
if none.boolean
boolean
isAssignableFrom
(JClassType possibleSubtype) boolean
isAssignableTo
(JClassType possibleSupertype) boolean
Determines if the class can be constructed using a simplenew
operation.boolean
Returns true if the type may be enhanced on the server to contain extra fields that are unknown to client code.boolean
isFinal()
boolean
Tests if this type is contained within another type.boolean
boolean
boolean
boolean
isPublic()
boolean
isStatic()
void
Indicates that the type may be enhanced on the server to contain extra fields that are unknown to client code.Methods inherited from interface com.google.gwt.core.ext.typeinfo.HasAnnotations
getAnnotation, getAnnotations, getDeclaredAnnotations, isAnnotationPresent
Methods inherited from interface com.google.gwt.core.ext.typeinfo.JType
getJNISignature, getLeafType, getParameterizedQualifiedSourceName, getQualifiedBinaryName, getQualifiedSourceName, getSimpleSourceName, isAnnotation, isArray, isClass, isClassOrInterface, isEnum, isGenericType, isInterface, isParameterized, isPrimitive, isRawType, isTypeParameter, isWildcard
-
Method Details
-
asParameterizationOf
-
findAnnotationInTypeHierarchy
Find an annotation on a type or on one of its superclasses or superinterfaces.This provides semantics similar to that of
Inherited
except that it checks all types to which this type is assignable.@Inherited
only works on superclasses, not superinterfaces.Annotations present on the superclass chain will be returned preferentially over those found in the superinterface hierarchy. Note that the annotation does not need to be tagged with
@Inherited
in order to be returned from the superclass chain.- Parameters:
annotationType
- the type of the annotation to look for- Returns:
- the desired annotation or
null
if the annotation is not present in the type's type hierarchy
-
findConstructor
Returns the constructor with parameters that have the given types, or null if not found. -
findField
-
findMethod
-
findNestedType
-
getConstructor
- Throws:
NotFoundException
-
getConstructors
JConstructor[] getConstructors() -
getEnclosingType
JClassType getEnclosingType()Returns the enclosing type, or null if none. -
getErasedType
JClassType getErasedType()Description copied from interface:JType
Returns this type with no type parameters or type variables. See the JLS Third Edition section on Type Erasure.- Specified by:
getErasedType
in interfaceJType
-
getField
-
getFields
JField[] getFields() -
getFlattenedSupertypeHierarchy
Set<? extends JClassType> getFlattenedSupertypeHierarchy()Returns all of the superclasses and superinterfaces for a given type including the type itself. The returned set maintains an internal breadth-first ordering of the type, followed by its interfaces (and their super-interfaces), then the supertype and its interfaces, and so on. -
getImplementedInterfaces
JClassType[] getImplementedInterfaces() -
getInheritableMethods
JMethod[] getInheritableMethods()Iterates over the most-derived declaration of each unique inheritable method available in the type hierarchy of the specified type, including those found in superclasses and superinterfaces. A method is inheritable if its accessibility ispublic
,protected
, or package protected. This method offers a convenient way for Generators to find candidate methods to call from a subclass.- Returns:
- an array of
JMethod
objects representing inheritable methods
-
getMethod
- Throws:
NotFoundException
-
getMethods
JMethod[] getMethods()Returns the declared methods of this class (not any superclasses or superinterfaces). -
getName
String getName()If an array, returns the name of this class without the package name or enclosing class name, followed by multiple pairs of square brackets; if not, returns the nested name of this type (like Foo or Foo.Bar), without the package name. -
getNestedType
- Throws:
NotFoundException
-
getNestedTypes
JClassType[] getNestedTypes() -
getOracle
TypeOracle getOracle() -
getOverloads
Returns the declared methods of this class with the given name (doesn't include any superclasses or superinterfaces). -
getOverridableMethods
JMethod[] getOverridableMethods()Iterates over the most-derived declaration of each unique overridable method available in the type hierarchy of the specified type, including those found in superclasses and superinterfaces. A method is overridable if it is notfinal
and its accessibility ispublic
,protected
, or package protected. Deferred binding generators often need to generate method implementations; this method offers a convenient way to find candidate methods to implement. Note that the behavior does not matchClass.getMethod(String, Class[])
, which does not return the most derived method in some cases.- Returns:
- an array of
JMethod
objects representing overridable methods
-
getPackage
JPackage getPackage() -
getSubtypes
JClassType[] getSubtypes()Returns all subtypes of this type, recursively, not including this type. -
getSuperclass
JClassType getSuperclass()Returns the superclass of this type, ornull
if none. -
isAbstract
boolean isAbstract() -
isAssignableFrom
- Parameters:
possibleSubtype
- possible subtype of thisJClassType
- Returns:
true
if thisJClassType
is assignable from the specifiedJClassType
parameter- Throws:
NullPointerException
- ifpossibleSubtype
isnull
-
isAssignableTo
- Parameters:
possibleSupertype
- possible supertype of thisJClassType
- Returns:
true
if thisJClassType
is assignable to the specifiedJClassType
parameter- Throws:
NullPointerException
- ifpossibleSupertype
isnull
-
isDefaultInstantiable
boolean isDefaultInstantiable()Determines if the class can be constructed using a simplenew
operation. Specifically, the class must- be a class rather than an interface,
- have either no constructors or a parameterless constructor, and
- be a top-level class or a static nested class.
- Returns:
true
if the type is default instantiable, orfalse
otherwise
-
isEnhanced
boolean isEnhanced()Returns true if the type may be enhanced on the server to contain extra fields that are unknown to client code.- Returns:
true
if the type might be enhanced on the server
-
isFinal
boolean isFinal() -
isMemberType
boolean isMemberType()Tests if this type is contained within another type.- Returns:
- true if this type has an enclosing type, false if this type is a top-level type
-
isPrivate
boolean isPrivate() -
isProtected
boolean isProtected() -
isPublic
boolean isPublic() -
isPackageProtected
boolean isPackageProtected() -
isStatic
boolean isStatic() -
setEnhanced
void setEnhanced()Indicates that the type may be enhanced on the server to contain extra fields that are unknown to client code. TODO(rice): find a better way to do this.
-