类 DefaultJavaType

java.lang.Object
com.thoughtworks.qdox.model.impl.DefaultJavaType
所有已实现的接口:
JavaAnnotatedElement, JavaClass, JavaGenericDeclaration, JavaModel, JavaType, Serializable
直接已知子类:
DefaultJavaParameterizedType, DefaultJavaTypeVariable, DefaultJavaWildcardType

public class DefaultJavaType extends Object implements JavaClass, JavaType, Serializable
The default implementation for JavaType
从以下版本开始:
2.0
作者:
Robert Scholte
另请参阅:
  • 字段详细资料

    • name

      protected final String name
    • fullName

      protected String fullName
  • 方法详细资料

    • 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
      另请参阅:
    • getSimpleName

      public String getSimpleName()
      Equivalent of Class.getSimpleName().
      指定者:
      getSimpleName 在接口中 JavaClass
      返回:
      the simple name of the underlying class as given in the source code.
    • 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
      另请参阅:
    • 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
    • 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
    • getGenericValue

      protected static <D extends JavaGenericDeclaration> String getGenericValue(JavaType base, List<JavaTypeVariable<D>> typeVariableList)
    • getResolvedValue

      protected static <D extends JavaGenericDeclaration> String getResolvedValue(JavaType base, List<JavaTypeVariable<D>> typeParameters)
    • resolve

      protected static <D extends JavaGenericDeclaration> JavaTypeVariable<D> resolve(JavaType base, List<JavaTypeVariable<D>> typeParameters)
    • isResolved

      protected boolean isResolved()
    • isArray

      public boolean isArray()
      指定者:
      isArray 在接口中 JavaClass
      返回:
      true if this JavaClass is an array, otherwise false
    • 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
    • toString

      public String toString()
      Equivalent of Class.toString(). Converts the object to a string.
      指定者:
      toString 在接口中 JavaClass
      覆盖:
      toString 在类中 Object
      返回:
      a string representation of this type.
      另请参阅:
    • toGenericString

      public String toGenericString()
      Returns getGenericValue() extended with the array information
       Object > java.lang.Object
       Object[] > java.lang.Object[]
       List<Object> > java.lang.List<java.lang.Object>
       Outer.Inner > Outer$Inner
       Outer.Inner<Object>[][] > Outer$Inner<java.lang.Object>[][] 
       
      指定者:
      toGenericString 在接口中 JavaType
      返回:
      a generic string representation of this type.
    • equals

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

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

      public boolean isA(JavaType type)
      参数:
      type - the type to match with
      返回:
      true if this type if of type, otherwise false
      从以下版本开始:
      1.3
    • 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
    • resolve

      protected static JavaType resolve(JavaType base, JavaClass declaringClass, JavaClass callingClass)
      Consider the following example
        public abstract class AbstractClass<T> 
        {
          private T value;
          
          public AbstractClass( T value ) { this.value = value; }
          
          public T getValue() { return value; }
        }
        
        public class ConcreteClass extends AbstractClass<String>
        {
          public ConcreteClass( String s ) { super( s ); }
        }
        

      We want to know the resolved returnType when calling ConcreteClass.getValue(). The expected type is String.

      • this would be T
      • declaringClass would be AbstractClass, since that's where T is used
      • callingClass would be ConcreteClass
      参数:
      base - the base
      declaringClass - the declaring class
      callingClass - the calling class
      返回:
      the resolved type
    • getGenericFullyQualifiedName

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

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

      protected static <D extends JavaGenericDeclaration> String getResolvedGenericValue(JavaType base, List<JavaTypeVariable<D>> typeParameters)
    • getResolvedGenericFullyQualifiedName

      protected static <D extends JavaGenericDeclaration> String getResolvedGenericFullyQualifiedName(JavaType base, List<JavaTypeVariable<D>> typeParameters)
    • getResolvedFullyQualifiedName

      protected static <D extends JavaGenericDeclaration> String getResolvedFullyQualifiedName(JavaType base, List<JavaTypeVariable<D>> typeParameters)
    • getSource

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

      public int getLineNumber()
      The line number where this element started
      指定者:
      getLineNumber 在接口中 JavaModel
      返回:
      the line number of this element
    • 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
    • getAnnotations

      public List<JavaAnnotation> getAnnotations()
      指定者:
      getAnnotations 在接口中 JavaAnnotatedElement
      返回:
      a list of Annotations, never null
    • 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
    • getComment

      public String getComment()
      Retrieve the javadoc comment of this annotated element. This is the part between /** and */, but without the Standard doclet block tags. It may still contain Standard doclet inline tags, though.
      指定者:
      getComment 在接口中 JavaAnnotatedElement
      返回:
      the comment, otherwise null
    • getTags

      public List<DocletTag> getTags()
      Retrieve all defined doclet tags.
      指定者:
      getTags 在接口中 JavaAnnotatedElement
      返回:
      a list of DocletTags, never null
    • 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
    • getTagsByName

      public List<DocletTag> getTagsByName(String name)
      Retrieve all doclettags with a specific name.
      指定者:
      getTagsByName 在接口中 JavaAnnotatedElement
      参数:
      name - the name of the doclet tag
      返回:
      a list of doclettags, never null
    • getTagByName

      public DocletTag getTagByName(String name)
      Retrieve the doclettag by the specified name. If there are more than one tags, only return the first one.
      指定者:
      getTagByName 在接口中 JavaAnnotatedElement
      参数:
      name - the name of the doclettag trying to retrieve
      返回:
      the first doclettag matching the name, otherwise null
    • 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
    • getNamedParameter

      public String getNamedParameter(String tagName, String parameterName)
      Convenience method for getTagByName(String).getNamedParameter(String) that also checks for null tag.
      指定者:
      getNamedParameter 在接口中 JavaAnnotatedElement
      参数:
      tagName - the tag name
      parameterName - the parameter name
      返回:
      the value of the matching parameter, otherwise null
    • getCodeBlock

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

      public <D extends JavaGenericDeclaration> List<JavaTypeVariable<D>> getTypeParameters()
      指定者:
      getTypeParameters 在接口中 JavaGenericDeclaration
      类型参数:
      D - the type
      返回:
      a list of typeParameters, never null
    • getParentSource

      public JavaSource getParentSource()
      指定者:
      getParentSource 在接口中 JavaClass
    • 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
    • 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
    • getMethods

      public List<JavaMethod> getMethods()
      Equivalent of Class.getMethods()
      指定者:
      getMethods 在接口中 JavaClass
      返回:
      the methods declared or overridden in this class
    • 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 varArg)
      指定者:
      getConstructor 在接口中 JavaClass
      参数:
      parameterTypes - the parameter types of the constructor, can be null
      varArg - define is the constructor has varArgs
      返回:
      the matching constructor, otherwise null
    • 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
    • getFields

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

      public JavaField getFieldByName(String name, boolean publicOnly, boolean supperClass)
      指定者:
      getFieldByName 在接口中 JavaClass
    • 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
    • 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
    • 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
    • getJavaClassLibrary

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

      public String getName()
      Equivalent of Class.getName().
      指定者:
      getName 在接口中 JavaClass
      返回:
      the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String.
    • getCanonicalName

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

      public 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.
      指定者:
      getModifiers 在接口中 JavaClass
      返回:
      all modifiers is this member
    • isPublic

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

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

      指定者:
      isPublic 在接口中 JavaClass
      返回:
      true if class has the public modifier, otherwise false
    • isProtected

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

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

      指定者:
      isProtected 在接口中 JavaClass
      返回:
      true if class has the protected modifier, otherwise false
    • isPrivate

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

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

      指定者:
      isPrivate 在接口中 JavaClass
      返回:
      true if class has the private modifier, otherwise false
    • isFinal

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

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

      指定者:
      isFinal 在接口中 JavaClass
      返回:
      true if class has the final modifier, otherwise false
    • isStatic

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

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

      指定者:
      isStatic 在接口中 JavaClass
      返回:
      true if class the static modifier, otherwise false
    • isAbstract

      public boolean isAbstract()
      (API description of Modifier.isAbstract(int)) Return true if the class includes the abstract modifier, false otherwise.
      指定者:
      isAbstract 在接口中 JavaClass
      返回:
      true if class has the abstract modifier, otherwise false
    • getDeclaringClass

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