Interface JClassType

    • Method Detail

      • findAnnotationInTypeHierarchy

        <T extends java.lang.annotation.Annotation> T findAnnotationInTypeHierarchy​(java.lang.Class<T> annotationType)
        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

        JConstructor findConstructor​(JType[] paramTypes)
        Returns the constructor with parameters that have the given types, or null if not found.
      • findField

        JField findField​(java.lang.String name)
      • findMethod

        JMethod findMethod​(java.lang.String name,
                           JType[] paramTypes)
      • findNestedType

        JClassType findNestedType​(java.lang.String typeName)
      • 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 interface JType
      • getField

        JField getField​(java.lang.String name)
      • getFields

        JField[] getFields()
      • getFlattenedSupertypeHierarchy

        java.util.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 is public, 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
      • getMethods

        JMethod[] getMethods()
        Returns the declared methods of this class (not any superclasses or superinterfaces).
      • getName

        java.lang.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.
      • getOverloads

        JMethod[] getOverloads​(java.lang.String name)
        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 not final and its accessibility is public, 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 match Class.getMethod(String, Class[]), which does not return the most derived method in some cases.
        Returns:
        an array of JMethod objects representing overridable methods
      • getSubtypes

        JClassType[] getSubtypes()
        Returns all subtypes of this type, recursively, not including this type.
      • getSuperclass

        JClassType getSuperclass()
        Returns the superclass of this type, or null if none.
      • isAbstract

        boolean isAbstract()
      • isAssignableFrom

        boolean isAssignableFrom​(JClassType possibleSubtype)
        Returns true if this JClassType is assignable from the specified JClassType parameter.
        Parameters:
        possibleSubtype - possible subtype of this JClassType
        Returns:
        true if this JClassType is assignable from the specified JClassType parameter
        Throws:
        java.lang.NullPointerException - if possibleSubtype is null
      • isAssignableTo

        boolean isAssignableTo​(JClassType possibleSupertype)
        Returns true if this JClassType is assignable to the specified JClassType parameter.
        Parameters:
        possibleSupertype - possible supertype of this JClassType
        Returns:
        true if this JClassType is assignable to the specified JClassType parameter
        Throws:
        java.lang.NullPointerException - if possibleSupertype is null
      • isDefaultInstantiable

        boolean isDefaultInstantiable()
        Determines if the class can be constructed using a simple new 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, or false 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.