Interface JavaClass

    • Method Detail

      • getSource

        JavaSource getSource()
        The compilation unit, which includes the imports, the public and anonymous classes
        Returns:
        the JavaSource of this element
      • isInterface

        boolean isInterface()
        (API description of Class.isInterface())

        Determines if the specified Class object represents an interface type.

        Returns:
        true if this object represents an interface, otherwise false
      • isEnum

        boolean isEnum()
        (API description of Class.isEnum())

        Returns true if and only if this class was declared as an enum in the source code.

        Returns:
        true if this object represents an enum, otherwise false
      • isAnnotation

        boolean isAnnotation()
        (API description of Class.isAnnotation())

        Returns true if this Class object represents an annotation type. Note that if this method returns true, isInterface() would also return true, as all annotation types are also interfaces.

        Returns:
        true if this object represents an annotation, otherwise false
        Since:
        2.0
      • getDeclaringClass

        JavaClass getDeclaringClass()
      • getSuperClass

        JavaType getSuperClass()
      • getSuperJavaClass

        JavaClass getSuperJavaClass()
        Shorthand for getSuperClass().getJavaClass() with null checking.
        Returns:
        the super class as JavaClass
      • getImplements

        java.util.List<JavaType> getImplements()
      • getInterfaces

        java.util.List<JavaClass> getInterfaces()
        Equivalent of Class.getInterfaces() Determines the interfaces implemented by the class or interface represented by this object.
        Returns:
        a list of interfaces, never null
        Since:
        2.0
      • getCodeBlock

        java.lang.String getCodeBlock()
        Specified by:
        getCodeBlock in interface JavaModel
        Returns:
        the codeblock
      • getPackage

        JavaPackage getPackage()
        Equivalent of Class.getPackage()
        Returns:
        the package
      • getPackageName

        java.lang.String getPackageName()
        If this class has a package, the packagename will be returned. Otherwise an empty String.
        Returns:
        the name of the package, otherwise an empty String
      • isInner

        boolean isInner()
        Returns:
        true if this class is an inner class, otherwise false
        Since:
        1.3
      • getMethods

        java.util.List<JavaMethod> getMethods()
        Equivalent of Class.getMethods()
        Returns:
        the methods declared or overridden in this class
      • getConstructors

        java.util.List<JavaConstructor> getConstructors()
        Equivalent of Class.getConstructors()
        Returns:
        the list of constructors
        Since:
        2.0
      • getConstructor

        JavaConstructor getConstructor​(java.util.List<JavaType> parameterTypes)
        Parameters:
        parameterTypes - the parameter types of the constructor, can be null
        Returns:
        the matching constructor, otherwise null
        Since:
        2.0
      • getConstructor

        JavaConstructor getConstructor​(java.util.List<JavaType> parameterTypes,
                                       boolean varArg)
        Parameters:
        parameterTypes - the parameter types of the constructor, can be null
        varArg - define is the constructor has varArgs
        Returns:
        the matching constructor, otherwise null
        Since:
        2.0
      • getMethods

        java.util.List<JavaMethod> getMethods​(boolean superclasses)
        Return declared methods and optionally the inherited methods
        Parameters:
        superclasses - true if inherited methods should be returned as well
        Returns:
        all methods
        Since:
        1.3
      • getMethodBySignature

        JavaMethod getMethodBySignature​(java.lang.String name,
                                        java.util.List<JavaType> parameterTypes)
        Parameters:
        name - the name of the method
        parameterTypes - the parameter types of the method, can be null.
        Returns:
        the matching method, otherwise null
      • getMethod

        JavaMethod getMethod​(java.lang.String name,
                             java.util.List<JavaType> parameterTypes,
                             boolean varArgs)
        This should be the signature for getMethodBySignature.
        Parameters:
        name - the name of the method
        parameterTypes - the parameter types of the method, can be null
        varArgs - define if the method has varArgs
        Returns:
        the matching method, otherwise null
      • getMethodBySignature

        JavaMethod getMethodBySignature​(java.lang.String name,
                                        java.util.List<JavaType> parameterTypes,
                                        boolean superclasses)
        Parameters:
        name - the name of the method
        parameterTypes - the parameter types of the method, can be null
        superclasses - to define if superclasses should be included as well
        Returns:
        the matching method, otherwise null
      • getMethodBySignature

        JavaMethod getMethodBySignature​(java.lang.String name,
                                        java.util.List<JavaType> parameterTypes,
                                        boolean superclasses,
                                        boolean varArg)
        Parameters:
        name - the name of the method
        parameterTypes - the parameter types of the method, can be null
        superclasses - true if inherited methods should be matched as well
        varArg - define if the method has varArgs
        Returns:
        the matching method, otherwise null
      • getMethodsBySignature

        java.util.List<JavaMethod> getMethodsBySignature​(java.lang.String name,
                                                         java.util.List<JavaType> parameterTypes,
                                                         boolean superclasses)
        Parameters:
        name - the name of the method
        parameterTypes - the parameter types of the method, can be null
        superclasses - true if inherited methods should be matched as well
        Returns:
        the matching methods, otherwise null
      • getMethodsBySignature

        java.util.List<JavaMethod> getMethodsBySignature​(java.lang.String name,
                                                         java.util.List<JavaType> parameterTypes,
                                                         boolean superclasses,
                                                         boolean varArg)
        Parameters:
        name - the name of the method
        parameterTypes - the parameter types of the method, can be null
        superclasses - true if inherited methods should be matched as well
        varArg - define if the method has varArgs
        Returns:
        the matching methods, otherwise null
      • getFields

        java.util.List<JavaField> getFields()
        Equivalent of Class.getFields()
        Returns:
        a list of fiels, never null
      • getFieldByName

        JavaField getFieldByName​(java.lang.String name)
        Equivalent of Class.getField(String), where this method can resolve every field
        Parameters:
        name - the name of the field
        Returns:
        the field
      • getEnumConstants

        java.util.List<JavaField> getEnumConstants()
        Based on Class.getEnumConstants().
        Returns:
        a List of enum constants if this class is an enum, otherwise null
      • getEnumConstantByName

        JavaField getEnumConstantByName​(java.lang.String name)
        Parameters:
        name - the name of the enum constant
        Returns:
        the enumConstant matching the name, otherwise null
      • getNestedClasses

        java.util.List<JavaClass> getNestedClasses()
        Equivalent of Class.getDeclaredClasses()
        Returns:
        a list of declared classes, never null
        Since:
        1.3
      • getNestedClassByName

        JavaClass getNestedClassByName​(java.lang.String name)
      • isA

        boolean isA​(java.lang.String fullyQualifiedName)
        Parameters:
        fullyQualifiedName - the FQN to match with
        Returns:
        true if this is of type FQN, otherwise false
        Since:
        1.3
      • isA

        boolean isA​(JavaClass javaClass)
        Parameters:
        javaClass - the JavaClass to match with
        Returns:
        true if this is of type javaClass, otherwise false
        Since:
        1.3
      • getDimensions

        int getDimensions()
        Returns the depth of this array, 0 if it's not an array
        Returns:
        The depth of this array, at least 0
        Since:
        2.0
      • isArray

        boolean isArray()
        Returns:
        true if this JavaClass is an array, otherwise false
        Since:
        2.0
      • isVoid

        boolean isVoid()
        Returns:
        true if this JavaClass is a void, otherwise false
        Since:
        2.0 (was part of Type since 1.6)
      • getComponentType

        JavaClass getComponentType()
        Equivalent of Class.getComponentType() If this type is an array, return its component type
        Returns:
        the type of array if it's one, otherwise null
      • getBeanProperties

        java.util.List<BeanProperty> getBeanProperties()
        Gets bean properties without looking in superclasses or interfaces.
        Returns:
        the bean properties
        Since:
        1.3
      • getBeanProperties

        java.util.List<BeanProperty> getBeanProperties​(boolean superclasses)
        Parameters:
        superclasses - to define if superclasses should be included as well
        Returns:
        the bean properties
        Since:
        1.3
      • getBeanProperty

        BeanProperty getBeanProperty​(java.lang.String propertyName)
        Gets bean property without looking in superclasses or interfaces.
        Parameters:
        propertyName - the name of the property
        Returns:
        the bean property
        Since:
        1.3
      • getBeanProperty

        BeanProperty getBeanProperty​(java.lang.String propertyName,
                                     boolean superclasses)
        Parameters:
        propertyName - the name of the property
        superclasses - to define if superclasses should be included as well
        Returns:
        the bean property
        Since:
        1.3
      • getDerivedClasses

        java.util.List<JavaClass> getDerivedClasses()
        Equivalent of Class.getClasses() Gets the known derived classes. That is, subclasses or implementing classes.
        Returns:
        the derived classes
      • getTagsByName

        java.util.List<DocletTag> getTagsByName​(java.lang.String name,
                                                boolean superclasses)
      • getInitializers

        java.util.List<JavaInitializer> getInitializers()
        A list if JavaInitializer, either static or instance initializers.
        Returns:
        a List of initializers
      • getName

        java.lang.String getName()
        Equivalent of Class.getName().
        Returns:
        the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String.
      • getSimpleName

        java.lang.String getSimpleName()
        Equivalent of Class.getSimpleName().
        Returns:
        the simple name of the underlying class as given in the source code.
        Since:
        2.0
      • getModifiers

        java.util.List<java.lang.String> getModifiers()
        Equivalent of Class.getModifiers() This does not follow the java-api The Class.getModifiers() returns an int, which should be decoded with the Modifier. This method will return a list of strings representing the modifiers. If this member was extracted from a source, it will keep its order. Otherwise if will be in the preferred order of the java-api.
        Returns:
        all modifiers is this member
      • isPublic

        boolean isPublic()
        (API description of Modifier.isPublic(int))

        Return true if the class includes the public modifier, false otherwise.

        Returns:
        true if class has the public modifier, otherwise false
      • isProtected

        boolean isProtected()
        (API description of Modifier.isProtected(int))

        Return true if the class includes the protected modifier, false otherwise.

        Returns:
        true if class has the protected modifier, otherwise false
      • isPrivate

        boolean isPrivate()
        (API description of Modifier.isPrivate(int))

        Return true if the class includes the private modifier, false otherwise.

        Returns:
        true if class has the private modifier, otherwise false
      • isFinal

        boolean isFinal()
        (API description of Modifier.isFinal(int))

        Return true if the class includes the final modifier, false otherwise.

        Returns:
        true if class has the final modifier, otherwise false
      • isStatic

        boolean isStatic()
        (API description of Modifier.isStatic(int))

        Return true if the class includes the static modifier, false otherwise.

        Returns:
        true if class the static modifier, otherwise false
      • isAbstract

        boolean isAbstract()
        (API description of Modifier.isAbstract(int)) Return true if the class includes the abstract modifier, false otherwise.
        Returns:
        true if class has the abstract modifier, otherwise false
      • isPrimitive

        boolean isPrimitive()
        Equivalent of Class.isPrimitive()
        Returns:
        true if this class represents a primitive, otherwise false
      • toString

        java.lang.String toString()
        (API description of Class.toString()) Converts the object to a string. The string representation is the string "class" or "interface", followed by a space, and then by the fully qualified name of the class in the format returned by getName. If this Class object represents a primitive type, this method returns the name of the primitive type. If this Class object represents void this method returns "void".
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of this class object.