接口 JavaClass

所有超级接口:
JavaAnnotatedElement, JavaGenericDeclaration, JavaModel, JavaType, Serializable
所有已知实现类:
DefaultJavaClass, DefaultJavaParameterizedType, DefaultJavaType, DefaultJavaTypeVariable, DefaultJavaWildcardType

public interface JavaClass extends JavaModel, JavaType, JavaAnnotatedElement, JavaGenericDeclaration
Equivalent of Class, providing the most important methods. Where the original Class is using an Array, this model is using a List.
作者:
Robert Scholte
  • 方法详细资料

    • getSource

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

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

      Determines if the specified Class object represents an interface type.

      返回:
      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.

      返回:
      true if this object represents an enum, otherwise false
    • isRecord

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

      Returns true if and only if this class was declared as a record in the source code.

      返回:
      true if this object represents a record, 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.

      返回:
      true if this object represents an annotation, otherwise false
      从以下版本开始:
      2.0
    • getDeclaringClass

      JavaClass getDeclaringClass()
    • getSuperClass

      JavaType getSuperClass()
    • getSuperJavaClass

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

      List<JavaType> getImplements()
    • getInterfaces

      List<JavaClass> getInterfaces()
      Equivalent of Class.getInterfaces() Determines the interfaces implemented by the class or interface represented by this object.
      返回:
      a list of interfaces, never null
      从以下版本开始:
      2.0
    • getCodeBlock

      String getCodeBlock()
      指定者:
      getCodeBlock 在接口中 JavaModel
      返回:
      the codeblock
    • getParentSource

      JavaSource getParentSource()
    • getPackage

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

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

      boolean isInner()
      返回:
      true if this class is an inner class, otherwise false
      从以下版本开始:
      1.3
    • getMethods

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

      List<JavaConstructor> getConstructors()
      返回:
      the list of constructors
      从以下版本开始:
      2.0
    • getConstructor

      JavaConstructor getConstructor(List<JavaType> parameterTypes)
      参数:
      parameterTypes - the parameter types of the constructor, can be null
      返回:
      the matching constructor, otherwise null
      从以下版本开始:
      2.0
    • getConstructor

      JavaConstructor getConstructor(List<JavaType> parameterTypes, boolean varArg)
      参数:
      parameterTypes - the parameter types of the constructor, can be null
      varArg - define is the constructor has varArgs
      返回:
      the matching constructor, otherwise null
      从以下版本开始:
      2.0
    • getMethods

      List<JavaMethod> getMethods(boolean superclasses)
      Return declared methods and optionally the inherited methods
      参数:
      superclasses - true if inherited methods should be returned as well
      返回:
      all methods
      从以下版本开始:
      1.3
    • getMethodBySignature

      JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes)
      参数:
      name - the name of the method
      parameterTypes - the parameter types of the method, can be null.
      返回:
      the matching method, otherwise null
    • getMethod

      JavaMethod getMethod(String name, List<JavaType> parameterTypes, boolean varArgs)
      This should be the signature for getMethodBySignature.
      参数:
      name - the name of the method
      parameterTypes - the parameter types of the method, can be null
      varArgs - define if the method has varArgs
      返回:
      the matching method, otherwise null
    • getMethodBySignature

      JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes, boolean superclasses)
      参数:
      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
      返回:
      the matching method, otherwise null
    • getMethodBySignature

      JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
      参数:
      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
      返回:
      the matching method, otherwise null
    • getMethodsBySignature

      List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses)
      参数:
      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
      返回:
      the matching methods, otherwise null
    • getMethodsBySignature

      List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
      参数:
      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
      返回:
      the matching methods, otherwise null
    • getFields

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

      JavaField getFieldByName(String name)
      Equivalent of Class.getField(String), where this method can resolve every field
      参数:
      name - the name of the field
      返回:
      the field
    • getFields

      List<JavaField> getFields(boolean publicOnly, boolean supperClass)
    • getFieldByName

      JavaField getFieldByName(String name, boolean publicOnly, boolean supperClass)
    • getEnumConstants

      List<JavaField> getEnumConstants()
      返回:
      a List of enum constants if this class is an enum, otherwise null
    • getEnumConstantByName

      JavaField getEnumConstantByName(String name)
      参数:
      name - the name of the enum constant
      返回:
      the enumConstant matching the name, otherwise null
    • getNestedClasses

      List<JavaClass> getNestedClasses()
      返回:
      a list of declared classes, never null
      从以下版本开始:
      1.3
    • getNestedClassByName

      JavaClass getNestedClassByName(String name)
    • isA

      boolean isA(String fullyQualifiedName)
      参数:
      fullyQualifiedName - the FQN to match with
      返回:
      true if this is of type FQN, otherwise false
      从以下版本开始:
      1.3
    • isA

      boolean isA(JavaClass javaClass)
      参数:
      javaClass - the JavaClass to match with
      返回:
      true if this is of type javaClass, otherwise false
      从以下版本开始:
      1.3
    • getDimensions

      int getDimensions()
      Returns the depth of this array, 0 if it's not an array
      返回:
      The depth of this array, at least 0
      从以下版本开始:
      2.0
    • isArray

      boolean isArray()
      返回:
      true if this JavaClass is an array, otherwise false
      从以下版本开始:
      2.0
    • isVoid

      boolean isVoid()
      返回:
      true if this JavaClass is a void, otherwise false
      从以下版本开始:
      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
      返回:
      the type of array if it's one, otherwise null
    • getBeanProperties

      List<BeanProperty> getBeanProperties()
      Gets bean properties without looking in superclasses or interfaces.
      返回:
      the bean properties
      从以下版本开始:
      1.3
    • getBeanProperties

      List<BeanProperty> getBeanProperties(boolean superclasses)
      参数:
      superclasses - to define if superclasses should be included as well
      返回:
      the bean properties
      从以下版本开始:
      1.3
    • getBeanProperty

      BeanProperty getBeanProperty(String propertyName)
      Gets bean property without looking in superclasses or interfaces.
      参数:
      propertyName - the name of the property
      返回:
      the bean property
      从以下版本开始:
      1.3
    • getBeanProperty

      BeanProperty getBeanProperty(String propertyName, boolean superclasses)
      参数:
      propertyName - the name of the property
      superclasses - to define if superclasses should be included as well
      返回:
      the bean property
      从以下版本开始:
      1.3
    • getDerivedClasses

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

      List<DocletTag> getTagsByName(String name, boolean superclasses)
    • getJavaClassLibrary

      ClassLibrary getJavaClassLibrary()
    • getInitializers

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

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

      String getSimpleName()
      Equivalent of Class.getSimpleName().
      返回:
      the simple name of the underlying class as given in the source code.
      从以下版本开始:
      2.0
    • getModifiers

      List<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.
      返回:
      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.

      返回:
      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.

      返回:
      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.

      返回:
      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.

      返回:
      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.

      返回:
      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.
      返回:
      true if class has the abstract modifier, otherwise false
    • isPrimitive

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

      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".
      覆盖:
      toString 在类中 Object
      返回:
      a string representation of this class object.