类 DefaultJavaClass

所有已实现的接口:
JavaAnnotatedElement, JavaClass, JavaGenericDeclaration, JavaModel, JavaType, Serializable

public class DefaultJavaClass extends AbstractInheritableJavaEntity implements JavaClass
作者:
Joe Walnes, Aslak Hellesøy
另请参阅:
  • 构造器详细资料

    • DefaultJavaClass

      protected DefaultJavaClass()
    • DefaultJavaClass

      public DefaultJavaClass(String name)
    • DefaultJavaClass

      public DefaultJavaClass(JavaSource source)
  • 方法详细资料

    • isInterface

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

      Determines if the specified Class object represents an interface type.

      指定者:
      isInterface 在接口中 JavaClass
      返回:
      true if this object represents an interface, otherwise false
    • isPrimitive

      public boolean isPrimitive()
      Equivalent of Class.isPrimitive()
      指定者:
      isPrimitive 在接口中 JavaClass
      返回:
      true if this class represents a primitive, otherwise false
    • isVoid

      public boolean isVoid()
      指定者:
      isVoid 在接口中 JavaClass
      返回:
      true if this JavaClass is a void, otherwise false
    • isEnum

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

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

      指定者:
      isEnum 在接口中 JavaClass
      返回:
      true if this object represents an enum, otherwise false
    • isRecord

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

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

      指定者:
      isRecord 在接口中 JavaClass
      返回:
      true if this object represents a record, otherwise false
    • isAnnotation

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

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

      指定者:
      isAnnotation 在接口中 JavaClass
      返回:
      true if this object represents an annotation, otherwise false
    • isArray

      public boolean isArray()
      指定者:
      isArray 在接口中 JavaClass
      返回:
      true if this JavaClass is an array, otherwise false
    • getComponentType

      public JavaClass getComponentType()
      Equivalent of Class.getComponentType() If this type is an array, return its component type
      指定者:
      getComponentType 在接口中 JavaClass
      返回:
      the type of array if it's one, otherwise null
    • getDimensions

      public int getDimensions()
      Returns the depth of this array, 0 if it's not an array
      指定者:
      getDimensions 在接口中 JavaClass
      返回:
      The depth of this array, at least 0
    • getSuperClass

      public JavaType getSuperClass()
      指定者:
      getSuperClass 在接口中 JavaClass
    • getSuperJavaClass

      public JavaClass getSuperJavaClass()
      Shorthand for getSuperClass().getJavaClass() with null checking.
      指定者:
      getSuperJavaClass 在接口中 JavaClass
      返回:
      the super class as JavaClass
    • getImplements

      public List<JavaType> getImplements()
      指定者:
      getImplements 在接口中 JavaClass
    • getInterfaces

      public List<JavaClass> getInterfaces()
      Equivalent of Class.getInterfaces() Determines the interfaces implemented by the class or interface represented by this object.
      指定者:
      getInterfaces 在接口中 JavaClass
      返回:
      a list of interfaces, never null
    • getCodeBlock

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

      public void setInterface(boolean anInterface)
    • setEnum

      public void setEnum(boolean anEnum)
    • setRecord

      public void setRecord(boolean aRecord)
    • setAnnotation

      public void setAnnotation(boolean anAnnotation)
    • addConstructor

      public void addConstructor(JavaConstructor constructor)
    • addMethod

      public void addMethod(JavaMethod meth)
    • setSuperClass

      public void setSuperClass(JavaType type)
    • setImplementz

      public void setImplementz(List<JavaClass> implementz)
    • getTypeParameters

      public List<DefaultJavaTypeVariable<JavaClass>> getTypeParameters()
      指定者:
      getTypeParameters 在接口中 JavaGenericDeclaration
      返回:
      a list of typeParameters, never null
    • setTypeParameters

      public void setTypeParameters(List<DefaultJavaTypeVariable<JavaClass>> typeParameters)
    • addField

      public void addField(JavaField javaField)
    • setJavaPackage

      public void setJavaPackage(JavaPackage javaPackage)
      Only used when constructing the model by hand / without source
      参数:
      javaPackage - the package
    • getParentSource

      public JavaSource getParentSource()
      指定者:
      getParentSource 在接口中 JavaClass
    • getSource

      public JavaSource getSource()
      The compilation unit, which includes the imports, the public and anonymous classes
      指定者:
      getSource 在接口中 JavaClass
      覆盖:
      getSource 在类中 AbstractBaseJavaEntity
      返回:
      the JavaSource of this element
    • getPackage

      public JavaPackage getPackage()
      Equivalent of Class.getPackage()
      指定者:
      getPackage 在接口中 JavaClass
      返回:
      the package
    • getPackageName

      public String getPackageName()
      If this class has a package, the packagename will be returned. Otherwise an empty String.
      指定者:
      getPackageName 在接口中 JavaClass
      返回:
      the name of the package, otherwise an empty String
    • getSimpleName

      public String getSimpleName()
      Equivalent of Class.getSimpleName().
      指定者:
      getSimpleName 在接口中 JavaClass
      返回:
      the simple name of the underlying class as given in the source code.
    • getBinaryName

      public String getBinaryName()
      The class or interface must be named by its binary name, which must meet the following constraints:
      • The binary name of a top level type is its canonical name.
      • The binary name of a member type consists of the binary name of its immediately enclosing type, followed by $, followed by the simple name of the member.
      指定者:
      getBinaryName 在接口中 JavaType
      返回:
      the binary name
      另请参阅:
    • getFullyQualifiedName

      public String getFullyQualifiedName()
      Every primitive type, named package, top level class, and top level interface has a fully qualified name:
      • The fully qualified name of a primitive type is the keyword for that primitive type, namely byte, short, char, int, long, float, double, or boolean.
      • The fully qualified name of a named package that is not a subpackage of a named package is its simple name.
      • The fully qualified name of a named package that is a subpackage of another named package consists of the fully qualified name of the containing package, followed by ".", followed by the simple (member) name of the subpackage.
      • The fully qualified name of a top level class or top level interface that is declared in an unnamed package is the simple name of the class or interface.
      • The fully qualified name of a top level class or top level interface that is declared in a named package consists of the fully qualified name of the package, followed by ".", followed by the simple name of the class or interface.
      Each member class, member interface, and array type may have a fully qualified name:
      • A member class or member interface M of another class or interface C has a fully qualified name if and only if C has a fully qualified name.
      • In that case, the fully qualified name of M consists of the fully qualified name of C, followed by ".", followed by the simple name of M.
      • An array type has a fully qualified name if and only if its element type has a fully qualified name.
      • In that case, the fully qualified name of an array type consists of the fully qualified name of the component type of the array type followed by "[]".
      Some examples how names will be translated
       Object > java.lang.Object
       java.util.List > java.util.List
       ?  > ?
       T  > T
       anypackage.Outer.Inner > anypackage.Outer.Inner
       String[][] > java.lang.String[][]
       
      指定者:
      getFullyQualifiedName 在接口中 JavaType
      返回:
      the fully qualified name, never null
      另请参阅:
    • getGenericFullyQualifiedName

      public String getGenericFullyQualifiedName()
      The fully qualified name with generic information.
      指定者:
      getGenericFullyQualifiedName 在接口中 JavaType
      返回:
      the generic fully qualified name
    • getCanonicalName

      public String getCanonicalName()
      Equivalent of (@link Class.getCanonicalName().
      指定者:
      getCanonicalName 在接口中 JavaType
      返回:
      the canonical name of this class
    • getGenericCanonicalName

      public String getGenericCanonicalName()
      The canonical name with generic information.
      指定者:
      getGenericCanonicalName 在接口中 JavaType
      返回:
      the generic canonical name
    • getValue

      public String getValue()
      If there's a reference to this class, use the value used in the code. Otherwise return the simple name. When including all imports, you should be safe to use this method. This won't return generics, so it's java1.4 safe. Examples:
        private String fieldA;             // getValue() will return "String"
        private java.lang.String fieldA;   // getValue() will return "java.lang.String"
        private List>String> aList;  // getValue() will return "List"
       
      指定者:
      getValue 在接口中 JavaType
      返回:
      the name of the class as used in the source
    • getGenericValue

      public String getGenericValue()
      A java5+ representation of the class. When including all imports, you should be safe to use this method. Examples:
        private String fieldA;             // getValue() will return "String"
        private java.lang.String fieldA;   // getValue() will return "java.lang.String"
        private List>String> aList;  // getValue() will return "List>String>"
       
      指定者:
      getGenericValue 在接口中 JavaType
      返回:
      the generic name of the class as used in the source
    • isInner

      public boolean isInner()
      指定者:
      isInner 在接口中 JavaClass
      返回:
      true if this class is an inner class, otherwise false
    • getInitializers

      public List<JavaInitializer> getInitializers()
      A list if JavaInitializer, either static or instance initializers.
      指定者:
      getInitializers 在接口中 JavaClass
      返回:
      a List of initializers
    • getConstructors

      public List<JavaConstructor> getConstructors()
      指定者:
      getConstructors 在接口中 JavaClass
      返回:
      the list of constructors
    • getConstructor

      public JavaConstructor getConstructor(List<JavaType> parameterTypes)
      指定者:
      getConstructor 在接口中 JavaClass
      参数:
      parameterTypes - the parameter types of the constructor, can be null
      返回:
      the matching constructor, otherwise null
    • getConstructor

      public JavaConstructor getConstructor(List<JavaType> parameterTypes, boolean varArgs)
      指定者:
      getConstructor 在接口中 JavaClass
      参数:
      parameterTypes - the parameter types of the constructor, can be null
      varArgs - define is the constructor has varArgs
      返回:
      the matching constructor, otherwise null
    • getMethods

      public List<JavaMethod> getMethods()
      Equivalent of Class.getMethods()
      指定者:
      getMethods 在接口中 JavaClass
      返回:
      the methods declared or overridden in this class
    • getMethods

      public List<JavaMethod> getMethods(boolean superclasses)
      Return declared methods and optionally the inherited methods
      指定者:
      getMethods 在接口中 JavaClass
      参数:
      superclasses - true if inherited methods should be returned as well
      返回:
      all methods
    • getMethodBySignature

      public JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes)
      指定者:
      getMethodBySignature 在接口中 JavaClass
      参数:
      name - the name of the method
      parameterTypes - the parameter types of the method, can be null.
      返回:
      the matching method, otherwise null
    • getMethod

      public JavaMethod getMethod(String name, List<JavaType> parameterTypes, boolean varArgs)
      This should be the signature for getMethodBySignature.
      指定者:
      getMethod 在接口中 JavaClass
      参数:
      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

      public JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes, boolean superclasses)
      指定者:
      getMethodBySignature 在接口中 JavaClass
      参数:
      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

      public JavaMethod getMethodBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
      指定者:
      getMethodBySignature 在接口中 JavaClass
      参数:
      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

      public List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses)
      指定者:
      getMethodsBySignature 在接口中 JavaClass
      参数:
      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

      public List<JavaMethod> getMethodsBySignature(String name, List<JavaType> parameterTypes, boolean superclasses, boolean varArg)
      指定者:
      getMethodsBySignature 在接口中 JavaClass
      参数:
      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

      public List<JavaField> getFields()
      Equivalent of Class.getFields()
      指定者:
      getFields 在接口中 JavaClass
      返回:
      a list of fiels, never null
    • getFieldByName

      public JavaField getFieldByName(String name)
      Equivalent of Class.getField(String), where this method can resolve every field
      指定者:
      getFieldByName 在接口中 JavaClass
      参数:
      name - the name of the field
      返回:
      the field
    • getFields

      public List<JavaField> getFields(boolean publicOnly, boolean supperClass)
      指定者:
      getFields 在接口中 JavaClass
    • getFieldByName

      public JavaField getFieldByName(String name, boolean publicOnly, boolean supperClass)
      指定者:
      getFieldByName 在接口中 JavaClass
    • getEnumConstants

      public List<JavaField> getEnumConstants()
      指定者:
      getEnumConstants 在接口中 JavaClass
      返回:
      a List of enum constants if this class is an enum, otherwise null
    • getEnumConstantByName

      public JavaField getEnumConstantByName(String name)
      指定者:
      getEnumConstantByName 在接口中 JavaClass
      参数:
      name - the name of the enum constant
      返回:
      the enumConstant matching the name, otherwise null
    • addInitializer

      public void addInitializer(JavaInitializer initializer)
    • addClass

      public void addClass(JavaClass cls)
    • getNestedClasses

      public List<JavaClass> getNestedClasses()
      指定者:
      getNestedClasses 在接口中 JavaClass
      返回:
      a list of declared classes, never null
    • getNestedClassByName

      public JavaClass getNestedClassByName(String name)
      指定者:
      getNestedClassByName 在接口中 JavaClass
    • isA

      public boolean isA(String fullClassName)
      指定者:
      isA 在接口中 JavaClass
      参数:
      fullClassName - the FQN to match with
      返回:
      true if this is of type FQN, otherwise false
    • isA

      public boolean isA(JavaClass javaClass)
      指定者:
      isA 在接口中 JavaClass
      参数:
      javaClass - the JavaClass to match with
      返回:
      true if this is of type javaClass, otherwise false
    • getBeanProperties

      public List<BeanProperty> getBeanProperties()
      Gets bean properties without looking in superclasses or interfaces.
      指定者:
      getBeanProperties 在接口中 JavaClass
      返回:
      the bean properties
    • getBeanProperties

      public List<BeanProperty> getBeanProperties(boolean superclasses)
      指定者:
      getBeanProperties 在接口中 JavaClass
      参数:
      superclasses - to define if superclasses should be included as well
      返回:
      the bean properties
    • getBeanProperty

      public BeanProperty getBeanProperty(String propertyName)
      Gets bean property without looking in superclasses or interfaces.
      指定者:
      getBeanProperty 在接口中 JavaClass
      参数:
      propertyName - the name of the property
      返回:
      the bean property
    • getBeanProperty

      public BeanProperty getBeanProperty(String propertyName, boolean superclasses)
      指定者:
      getBeanProperty 在接口中 JavaClass
      参数:
      propertyName - the name of the property
      superclasses - to define if superclasses should be included as well
      返回:
      the bean property
    • getDerivedClasses

      public List<JavaClass> getDerivedClasses()
      Equivalent of Class.getClasses() Gets the known derived classes. That is, subclasses or implementing classes.
      指定者:
      getDerivedClasses 在接口中 JavaClass
      返回:
      the derived classes
    • getTagsByName

      public List<DocletTag> getTagsByName(String name, boolean superclasses)
      指定者:
      getTagsByName 在接口中 JavaClass
      指定者:
      getTagsByName 在类中 AbstractInheritableJavaEntity
    • toString

      public String toString()
      从接口复制的说明: JavaClass
      (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 在接口中 JavaClass
      覆盖:
      toString 在类中 Object
      返回:
      a string representation of this class object.
      另请参阅:
    • toGenericString

      public String toGenericString()
      指定者:
      toGenericString 在接口中 JavaType
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • equals

      public boolean equals(Object obj)
      覆盖:
      equals 在类中 Object
    • getJavaClassLibrary

      public ClassLibrary getJavaClassLibrary()
      指定者:
      getJavaClassLibrary 在接口中 JavaClass