Package com.tngtech.archunit.core.domain
Class JavaClass
java.lang.Object
com.tngtech.archunit.core.domain.JavaClass
- All Implemented Interfaces:
HasDescription,JavaType,CanBeAnnotated,HasAnnotations<JavaClass>,HasModifiers,HasName,HasName.AndFullName,HasSourceCodeLocation,HasTypeParameters<JavaClass>
@PublicAPI(usage=ACCESS)
public final class JavaClass
extends Object
implements JavaType, HasName.AndFullName, HasTypeParameters<JavaClass>, HasAnnotations<JavaClass>, HasModifiers, HasSourceCodeLocation
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final classPredefinedpredicatestargetingJavaClass.Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.CanBeAnnotated
CanBeAnnotated.UtilsNested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasName
HasName.AndFullName, HasName.Utils -
Method Summary
Modifier and TypeMethodDescriptionSet<JavaAccess<?>>Set<JavaAccess<?>>LikegetAccessesFromSelf()but this class is target instead of origin.Set<JavaAccess<?>>Returns the set of all raw types that are involved in this type.<A extends Annotation>
AgetAnnotationOfType(Class<A> type) getAnnotationOfType(String typeName) Set<JavaAnnotation<?>>Set<JavaAnnotation<?>>The base component type is the class'component typeif it is a one-dimensional array, the repeated application ofgetComponentType()if it is a multi-dimensional array, or the class itself if it is no array.LikegetCodeUnitAccessesFromSelf()but this class is target instead of origin.Returns all calls of this class to methods or constructors.LikegetCodeUnitCallsFromSelf()but this class is target instead of origin.LikegetCodeUnitReferencesFromSelf()but this class is target instead of origin.getCodeUnitWithParameterTypeNames(String name, String... parameters) Same asgetCodeUnitWithParameterTypes(String, Class[]), but with parameter signature specified as full class namesgetCodeUnitWithParameterTypeNames(String name, List<String> parameters) getCodeUnitWithParameterTypes(String name, Class<?>... parameters) getCodeUnitWithParameterTypes(String name, List<Class<?>> parameters) This is a convenience method fortryGetComponentType()in cases where clients know that this type is certainly an array type and thus the component type present.getConstructor(Class<?>... parameters) getConstructor(String... parameters) Same asgetConstructor(Class[]), but with parameter signature specified as full class names.LikegetConstructorCallsFromSelf()but this class is target instead of origin.LikegetConstructorReferencesFromSelf()but this class is target instead of origin.LikegetDirectDependenciesFromSelf(), but instead returns all dependencies where this class is target.Returns the enclosing class if this class is nested within another class.Returns the enclosingJavaCodeUnitif this class is declared within the context of aJavaCodeUnit, e.g.getEnumConstant(String name) Same asgetMethod(String, Class[]), but with parameter signature specified as fully qualified class names.LikegetMethodCallsFromSelf()but this class is target instead of origin.LikegetMethodReferencesFromSelf()but this class is target instead of origin.getName()Set<ThrowsDeclaration<? extends JavaCodeUnit>>Returns the transitive closure of all dependencies originating from this class, i.e.booleanisAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Returnstrue, if this element is annotated with an annotation matching the given predicate.booleanisAnnotatedWith(Class<? extends Annotation> annotationType) Returnstrue, if this element is annotated with the given annotation type.booleanisAnnotatedWith(String annotationTypeName) booleanbooleanAn anonymous class is an inner class that is automatically derived from a class creation expression with a declared class body, e.g.booleanisArray()booleanisAssignableFrom(DescribedPredicate<? super JavaClass> predicate) booleanisAssignableFrom(Class<?> type) booleanisAssignableFrom(String typeName) booleanisAssignableTo(DescribedPredicate<? super JavaClass> predicate) booleanisAssignableTo(Class<?> type) booleanisAssignableTo(String typeName) booleanisEnum()booleanisEquivalentTo(Class<?> clazz) booleanbooleanAn inner class is a nested class that is not explicitly or implicitly declared static.
Example:booleanbooleanA local class is a nested class that is not a member of any class and that has a name.
Example:booleanA member class is a class whose declaration is directly enclosed in the body of another class or interface declaration.
Example:booleanisMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Returnstrue, if this element is meta-annotated with an annotation matching the given predicate.booleanisMetaAnnotatedWith(Class<? extends Annotation> type) Returnstrue, if this element is meta-annotated with the given annotation type.booleanisMetaAnnotatedWith(String typeName) booleanA nested class is any class whose declaration occurs within the body of another class or interface.
Example:booleanbooleanisRecord()Returns whether this class is a record according to the Java Language Specification.booleanA top level class is a class that is not a nested class, i.e.Class<?>reflect()Converts thisJavaTypeinto the erased type (compare the Java Language Specification).toString()<A extends Annotation>
Optional<A>tryGetAnnotationOfType(Class<A> type) tryGetAnnotationOfType(String typeName) Same astryGetAnnotationOfType(Class), but takes the type name.tryGetCodeUnitWithParameterTypeNames(String name, List<String> parameters) Same asgetCodeUnitWithParameterTypeNames(String, List), but will returnOptional.empty()if there is no suchJavaCodeUnit.tryGetCodeUnitWithParameterTypes(String name, List<Class<?>> parameters) Same asgetCodeUnitWithParameterTypes(String, List), but will returnOptional.empty()if there is no suchJavaCodeUnit.Returns the component type of this class, if this class is an array, otherwiseOptional.empty().tryGetConstructor(Class<?>... parameters) tryGetConstructor(String... parameters) Same astryGetConstructor(Class[]), but with parameter signature specified as fully qualified class names.tryGetEnumConstant(String name) tryGetField(String name) tryGetMethod(String name) tryGetMethod(String name, Class<?>... parameters) tryGetMethod(String name, String... parameters) Same astryGetMethod(String, Class[]), but with parameter signature specified as fully qualified class names.
-
Method Details
-
getSource
-
getSourceCodeLocation
- Specified by:
getSourceCodeLocationin interfaceHasSourceCodeLocation- Returns:
- The
SourceCodeLocationof this object, i.e. how to locate the respective object within the set of source files.
-
getDescription
- Specified by:
getDescriptionin interfaceHasDescription
-
getName
- Specified by:
getNamein interfaceHasName- Returns:
- The fully qualified name of this
JavaClass, compareClass.getName()of the Reflection API
-
getFullName
- Specified by:
getFullNamein interfaceHasName.AndFullName- Returns:
- The fully qualified name of this
JavaClass, i.e. the result is the same as invokinggetName()
-
getSimpleName
-
getPackage
-
getPackageName
-
isPrimitive
-
isInterface
-
isEnum
-
isAnnotation
-
isRecord
Returns whether this class is a record according to the Java Language Specification.Records were added as preview feature with JDK 14/15 and were released as regular feature with JDK 16.
See also JEP 395: Records
-
tryGetEnumConstant
-
getEnumConstant
-
getEnumConstants
-
isArray
-
getComponentType
This is a convenience method fortryGetComponentType()in cases where clients know that this type is certainly an array type and thus the component type present.- Returns:
- The result of
tryGetComponentType() - Throws:
IllegalStateException- if this class is no array
-
tryGetComponentType
Returns the component type of this class, if this class is an array, otherwiseOptional.empty(). The component type is the type of the elements of an array type. ConsiderString[], then the component type would beString. Likewise forString[][]the component type would beString[].- Returns:
- The component type, if this type is an array, otherwise
Optional.empty()
-
getBaseComponentType
The base component type is the class'component typeif it is a one-dimensional array, the repeated application ofgetComponentType()if it is a multi-dimensional array, or the class itself if it is no array. For example, the base component type ofint,int[],int[][], ... is alwaysint.- Returns:
- The base component type of this class
-
isTopLevelClass
A top level class is a class that is not a nested class, i.e. not declared within the body of another class.
Example:
Of all these class declarations onlypublic class TopLevel { class NestedNonStatic {} static class NestedStatic {} void method() { class NestedLocal {} new NestedAnonymous() {} } }TopLevelis a top level class, since all other classes are declared within the body ofTopLeveland are thereby nested classes.
Compare e.g. Java Language Specification- Returns:
trueif this class is a top level class, i.e. not nested inside of any other class,falseotherwise- See Also:
-
isNestedClass
A nested class is any class whose declaration occurs within the body of another class or interface.
Example:
All classespublic class TopLevel { class NestedNonStatic {} static class NestedStatic {} void method() { class NestedLocal {} new NestedAnonymous() {} } }NestedNonStatic,NestedStatic,NestedLocaland the class the compiler creates for the anonymous class derived from"new NestedAnonymous() {}"(which will have some generated name likeTopLevel$1) are considered nested classes.TopLevelon the other side is no nested class.
Compare e.g. Java Language Specification- Returns:
trueif this class is nested, i.e. declared within another class,falseotherwise (i.e. for top-level classes)- See Also:
-
isMemberClass
A member class is a class whose declaration is directly enclosed in the body of another class or interface declaration.
Example:
Bothpublic class TopLevel { class MemberClassNonStatic {} static class MemberClassStatic {} void method() { class NoMemberLocal {} new NoMemberAnonymous() {} } }MemberClassNonStaticandMemberClassStaticare member classes, since they are directly declared within the body ofTopLevel. On the other handNoMemberLocaland the class the compiler creates for the anonymous class derived from"new NoMemberAnonymous() {}"(which will have some generated name likeTopLevel$1), as well asTopLevelitself, are not considered member classes.
Compare e.g. Java Language Specification- Returns:
trueif this class is a member class, i.e. directly declared within the body of another class,falseotherwise- See Also:
-
isInnerClass
An inner class is a nested class that is not explicitly or implicitly declared static.
Example:
The classespublic class TopLevel { class InnerMemberClass {} static class NoInnerClassSinceDeclaredStatic {} interface NoInnerClassSinceInterface {} void method() { class InnerLocalClass {} new InnerAnonymousClass() {} } }InnerMemberClass,InnerLocalClassand the class the compiler creates for the anonymous class derived from"new InnerAnonymousClass() {}"(which will have some generated name likeTopLevel$1) are inner classes since they are nested but not static. On the other handNoInnerClassSinceDeclaredStatic,NoInnerClassSinceInterfaceandTopLevelare no inner classes, because the former two explicitly or implicitly have thestaticmodifier while the latter one is a top level class.
Compare e.g. Java Language Specification- Returns:
trueif this class is an inner class (i.e. nested but non-static)falseotherwise- See Also:
-
isLocalClass
A local class is a nested class that is not a member of any class and that has a name.
Example:
Only The classpublic class TopLevel { class InnerClass {} static class NestedStaticClass {} void method() { class LocalClass {} new AnonymousClass() {} } }LocalClassis a local class, since it is a nested class that is not a member class, but it has the name "LocalClass".
All the other classesTopLevel,InnerClass,NestedStaticClassand the class the compiler creates for the anonymous class derived from"new AnonymousClass() {}"(which will have some generated name likeTopLevel$1) are considered non-local, since they either are top level, directly declared within the body ofTopLevelor are anonymous and thus have no name.
Compare e.g. Java Language Specification- Returns:
trueif this class is local class,falseotherwise- See Also:
-
isAnonymousClass
An anonymous class is an inner class that is automatically derived from a class creation expression with a declared class body, e.g.new Example(){ <some-body> }.
The compiler will automatically create a class backing this instance, typically with an autogenerated name likeSomeClass$1, whereSomeClassis the class holding the class creation expression.
Example:
Only the class the compiler creates for the anonymous class derived frompublic class TopLevel { class InnerClass {} static class NestedStaticClass {} void method() { class LocalClass {} new AnonymousClass() {} } }"new AnonymousClass() {}"(which will have some generated name likeTopLevel$1) is considered an anonymous class.
All the other classesTopLevel,InnerClass,NestedStaticClassandLocalClassare considered non-anonymous.
Compare e.g. Java Language Specification- Returns:
trueif this class is an anonymous class,falseotherwise- See Also:
-
getModifiers
- Specified by:
getModifiersin interfaceHasModifiers
-
isAnnotatedWith
Description copied from interface:CanBeAnnotatedReturnstrue, if this element is annotated with the given annotation type.- Specified by:
isAnnotatedWithin interfaceCanBeAnnotated- Parameters:
annotationType- The type of the annotation to check for
-
isAnnotatedWith
- Specified by:
isAnnotatedWithin interfaceCanBeAnnotated- Parameters:
annotationTypeName- Fully qualified class name of a specific type ofAnnotation- See Also:
-
isAnnotatedWith
@PublicAPI(usage=ACCESS) public boolean isAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Description copied from interface:CanBeAnnotatedReturnstrue, if this element is annotated with an annotation matching the given predicate.- Specified by:
isAnnotatedWithin interfaceCanBeAnnotated- Parameters:
predicate- Qualifies matching annotations
-
isMetaAnnotatedWith
Description copied from interface:CanBeAnnotatedReturnstrue, if this element is meta-annotated with the given annotation type. A meta-annotation is an annotation that is declared on another annotation.This method also returns
trueif this element is directly annotated with the given annotation type.- Specified by:
isMetaAnnotatedWithin interfaceCanBeAnnotated- Parameters:
type- The type of the annotation to check for
-
isMetaAnnotatedWith
- Specified by:
isMetaAnnotatedWithin interfaceCanBeAnnotated- Parameters:
typeName- Fully qualified class name of a specific type ofAnnotation- See Also:
-
isMetaAnnotatedWith
@PublicAPI(usage=ACCESS) public boolean isMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Description copied from interface:CanBeAnnotatedReturnstrue, if this element is meta-annotated with an annotation matching the given predicate. A meta-annotation is an annotation that is declared on another annotation.This method also returns
trueif this element is directly annotated with an annotation matching the given predicate.- Specified by:
isMetaAnnotatedWithin interfaceCanBeAnnotated- Parameters:
predicate- Qualifies matching annotations
-
getAnnotationOfType
- Specified by:
getAnnotationOfTypein interfaceHasAnnotations<JavaClass>- Type Parameters:
A- The type of theAnnotationto retrieve- Parameters:
type- A given annotation type to matchJavaAnnotationsagainst- Returns:
- An
Annotationof the given annotation type - Throws:
IllegalArgumentException- if the class is not annotated with the given type- See Also:
-
getAnnotationOfType
- Specified by:
getAnnotationOfTypein interfaceHasAnnotations<JavaClass>- Parameters:
typeName- The fully qualified class name of theAnnotationtype to retrieve.- Returns:
- The
JavaAnnotationmatching the given type. Will throw anIllegalArgumentExceptionif no matchingAnnotationis present. - See Also:
-
getAnnotations
- Specified by:
getAnnotationsin interfaceHasAnnotations<JavaClass>
-
tryGetAnnotationOfType
@PublicAPI(usage=ACCESS) public <A extends Annotation> Optional<A> tryGetAnnotationOfType(Class<A> type) - Specified by:
tryGetAnnotationOfTypein interfaceHasAnnotations<JavaClass>- Type Parameters:
A- The type of theAnnotationto retrieve- Parameters:
type- A given annotation type to matchJavaAnnotationsagainst- Returns:
- An
Optionalcontaining anAnnotationof the given annotation type, if this class is annotated with the given type, otherwise Optional.absent() - See Also:
-
tryGetAnnotationOfType
@PublicAPI(usage=ACCESS) public Optional<JavaAnnotation<JavaClass>> tryGetAnnotationOfType(String typeName) Same astryGetAnnotationOfType(Class), but takes the type name.- Specified by:
tryGetAnnotationOfTypein interfaceHasAnnotations<JavaClass>- Parameters:
typeName- The fully qualified class name of theAnnotationtype to retrieve.- Returns:
- The
JavaAnnotationmatching the given type orOptional.empty()if there is noAnnotationwith the respective annotation type. - See Also:
-
getTypeParameters
- Specified by:
getTypeParametersin interfaceHasTypeParameters<JavaClass>- Returns:
- the type parameters of this object, e.g. for any generic method
this would return the<A, B> B someMethod(A a) {..}JavaTypeVariables[A, B].
If this object is non-generic, e.g. a method
an empty list will be returned.void someMethod() {..}
-
getInstanceofChecks
-
getReferencedClassObjects
-
toErasure
Description copied from interface:JavaTypeConverts thisJavaTypeinto the erased type (compare the Java Language Specification). In particular this will result in- the class itself, if this type is a
JavaClass - the
JavaClassequivalent toObject, if this type is an unboundJavaTypeVariable - the
JavaClassequivalent to the erasure of the left most bound, if this type is a boundJavaTypeVariable - if this type is a
JavaGenericArrayType, the erasure will be theJavaClassequivalent to the array type that has the erasure of the generic component type of this type as its component type; e.g. take the generic array typeT[][]whereTis unbound, then the erasure will be the array typeObject[][]
- the class itself, if this type is a
-
getAllInvolvedRawTypes
Description copied from interface:JavaTypeReturns the set of all raw types that are involved in this type. If this type is aJavaClass, then this method trivially returns only the class itself. If this type is aJavaParameterizedType,JavaTypeVariable,JavaWildcardType, etc., then this method returns all raw types involved in type arguments and upper and lower bounds recursively. If this type is an array type, then this method returns all raw types involved in the component type of the array type.
Examples:
For the parameterized type
the result would be theList<String>classes[List, String].
For the parameterized type
the result would beMap<? extends Serializable, List<? super Integer[]>>[Map, Serializable, List, Integer].
And for the type variable
the result would beT extends List<? super Integer>[List, Integer].
Thus, this method offers a quick way to determine all types a (possibly complex) type depends on.- Specified by:
getAllInvolvedRawTypesin interfaceJavaType- Returns:
- All raw types involved in this
JavaType
-
getRawSuperclass
-
getSuperclass
-
getClassHierarchy
- Returns:
- The complete class hierarchy, i.e. the class itself and the result of
getAllRawSuperclasses()
-
getAllRawSuperclasses
- Returns:
- All super classes sorted ascending by distance in the class hierarchy, i.e. first the direct super class, then the super class of the super class and so on. Includes Object.class in the result.
-
getSubclasses
-
getInterfaces
-
getRawInterfaces
-
getAllRawInterfaces
-
getAllClassesSelfIsAssignableTo
- Returns:
- All classes, this class is assignable to, in particular
- self
- superclasses this class extends
- interfaces this class implements
-
getEnclosingClass
Returns the enclosing class if this class is nested within another class. OtherwiseOptional.empty().
Take for example
Thenclass OuterClass { class InnerClass{ } }InnerClass.getEnclosingClass()would returnOptional.of(OuterClass). WhileOuterClass.getEnclosingClass()would returnOptional.empty(). -
getEnclosingCodeUnit
Returns the enclosingJavaCodeUnitif this class is declared within the context of aJavaCodeUnit, e.g. a method or a constructor. OtherwiseOptional.empty().
Take for example
Thenclass OuterClass { OuterClass() { // creates a new anonymous class within the scope of the constructor new Serializable() {}; } void someMethod() { // creates a new local class within the scope of the method class LocalClass {} } class InnerClass {} }anonymousSerializable.getEnclosingCodeUnit()would return theJavaConstructorOuterClass()andLocalClass.getEnclosingCodeUnit()would return theJavaMethodvoid someMethod().
On the other handOuterClass.getEnclosingCodeUnit()orInnerClass.getEnclosingCodeUnit()would returnOptional.empty(), since they are not defined within the context of aJavaCodeUnit. -
getAllSubclasses
-
getMembers
-
getAllMembers
-
getFields
-
getAllFields
-
getField
- Returns:
- The field with the given name.
- Throws:
IllegalArgumentException- If this class does not have such a field.
-
tryGetField
- Returns:
- The field with the given name, if this class has such a field, otherwise
Optional.empty().
-
getCodeUnits
-
getCodeUnitWithParameterTypes
@PublicAPI(usage=ACCESS) public JavaCodeUnit getCodeUnitWithParameterTypes(String name, Class<?>... parameters) - Parameters:
name- The name of the code unit, can be a method name, but alsoCONSTRUCTOR_NAMEorSTATIC_INITIALIZER_NAMEparameters- The parameter signature of the method specified asClassObjects- Returns:
- A code unit (method, constructor or static initializer) with the given signature
-
getCodeUnitWithParameterTypeNames
@PublicAPI(usage=ACCESS) public JavaCodeUnit getCodeUnitWithParameterTypeNames(String name, String... parameters) Same asgetCodeUnitWithParameterTypes(String, Class[]), but with parameter signature specified as full class names -
getCodeUnitWithParameterTypes
@PublicAPI(usage=ACCESS) public JavaCodeUnit getCodeUnitWithParameterTypes(String name, List<Class<?>> parameters) -
tryGetCodeUnitWithParameterTypes
@PublicAPI(usage=ACCESS) public Optional<JavaCodeUnit> tryGetCodeUnitWithParameterTypes(String name, List<Class<?>> parameters) Same asgetCodeUnitWithParameterTypes(String, List), but will returnOptional.empty()if there is no suchJavaCodeUnit. -
getCodeUnitWithParameterTypeNames
@PublicAPI(usage=ACCESS) public JavaCodeUnit getCodeUnitWithParameterTypeNames(String name, List<String> parameters) -
tryGetCodeUnitWithParameterTypeNames
@PublicAPI(usage=ACCESS) public Optional<JavaCodeUnit> tryGetCodeUnitWithParameterTypeNames(String name, List<String> parameters) Same asgetCodeUnitWithParameterTypeNames(String, List), but will returnOptional.empty()if there is no suchJavaCodeUnit. -
getMethod
- Returns:
- The method with the given name and with zero parameters.
- Throws:
IllegalArgumentException- If this class does not have such a method.
-
getMethod
- Returns:
- The method with the given name and the given raw parameter types.
- Throws:
IllegalArgumentException- If this class does not have such a method.
-
getMethod
Same asgetMethod(String, Class[]), but with parameter signature specified as fully qualified class names. -
tryGetMethod
- Returns:
- The method with the given name and with zero parameters,
if this class has such a method, otherwise
Optional.empty().
-
tryGetMethod
@PublicAPI(usage=ACCESS) public Optional<JavaMethod> tryGetMethod(String name, Class<?>... parameters) - Returns:
- The method with the given name and the given parameter types,
if this class has such a method, otherwise
Optional.empty().
-
tryGetMethod
@PublicAPI(usage=ACCESS) public Optional<JavaMethod> tryGetMethod(String name, String... parameters) Same astryGetMethod(String, Class[]), but with parameter signature specified as fully qualified class names. -
getMethods
-
getAllMethods
-
getConstructor
- Returns:
- The constructor with zero parameters.
- Throws:
IllegalArgumentException- If this class does not have such a constructor.
-
getConstructor
- Returns:
- The constructor with the given parameter types. Note that these are the raw parameter types, which can
include synthetic parameter types under certain circumstances. For example inner classes have the outer
class as synthetic first parameter type and enums have a
Stringname andintordinal as prepended synthetic parameters. Unfortunately there is no fixed rule, e.g. local class constructors can have multiple synthetic parameters appended to the parameters derived from the source code. - Throws:
IllegalArgumentException- If this class does not have a constructor with the given parameter types.
-
getConstructor
Same asgetConstructor(Class[]), but with parameter signature specified as full class names. -
tryGetConstructor
- Returns:
- The constructor with zero parameters,
if this class has such a constructor, otherwise
Optional.empty().
-
tryGetConstructor
- Returns:
- The constructor with the given parameter types (compare
getConstructor(Class[])), if this class has such a constructor, otherwiseOptional.empty().
-
tryGetConstructor
Same astryGetConstructor(Class[]), but with parameter signature specified as fully qualified class names. -
getConstructors
-
getAllConstructors
-
getStaticInitializer
-
getAccessesFromSelf
- Returns:
- All accesses of this class to any members (fields/methods/constructors)
- See Also:
-
getAllAccessesFromSelf
- Returns:
getAccessesFromSelf()but for every class in the class hierarchy (i.e. all superclasses)
-
getFieldAccessesFromSelf
-
getCodeUnitAccessesFromSelf
- Returns:
- All access of this class to other code units. This can be calls to methods/constructors (e.g.
someExample.call()) or references of methods/constructors (e.g.SomeExample::call) - See Also:
-
getCodeUnitCallsFromSelf
Returns all calls of this class to methods or constructors. -
getMethodCallsFromSelf
- Returns:
- All method calls (e.g. a call to
SomeExample.someMethod()) - See Also:
-
getConstructorCallsFromSelf
- Returns:
- All constructor calls (e.g. a call to
SomeExample()) - See Also:
-
getCodeUnitReferencesFromSelf
- Returns:
- All references of this class to
methodorconstructor references. - See Also:
-
getMethodReferencesFromSelf
- Returns:
- All method references (e.g.
SomeExample::someMethod) - See Also:
-
getConstructorReferencesFromSelf
- Returns:
- All constructor references (e.g.
SomeExample::new) - See Also:
-
getDirectDependenciesFromSelf
- Returns:
- All dependencies originating directly from this class (i.e. where this class is the origin).
For further details about dependencies refer to
Dependency.
-
getTransitiveDependenciesFromSelf
Returns the transitive closure of all dependencies originating from this class, i.e. its direct dependencies and the dependencies from all imported target classes.- Returns:
- all transitive dependencies (including direct dependencies) from this class
- See Also:
-
getDirectDependenciesToSelf
LikegetDirectDependenciesFromSelf(), but instead returns all dependencies where this class is target.- Returns:
- Dependencies where this class is the target.
-
getFieldAccessesToSelf
-
getCodeUnitAccessesToSelf
LikegetCodeUnitAccessesFromSelf()but this class is target instead of origin. -
getCodeUnitCallsToSelf
LikegetCodeUnitCallsFromSelf()but this class is target instead of origin. -
getCodeUnitReferencesToSelf
LikegetCodeUnitReferencesFromSelf()but this class is target instead of origin. -
getMethodCallsToSelf
LikegetMethodCallsFromSelf()but this class is target instead of origin. -
getMethodReferencesToSelf
LikegetMethodReferencesFromSelf()but this class is target instead of origin. -
getConstructorCallsToSelf
LikegetConstructorCallsFromSelf()but this class is target instead of origin. -
getConstructorReferencesToSelf
LikegetConstructorReferencesFromSelf()but this class is target instead of origin. -
getAccessesToSelf
LikegetAccessesFromSelf()but this class is target instead of origin. -
getFieldsWithTypeOfSelf
- Returns:
- Fields of all imported classes that have the type of this class.
-
getMethodsWithParameterTypeOfSelf
- Returns:
- Methods of all imported classes that have a parameter type of this class.
-
getMethodsWithReturnTypeOfSelf
- Returns:
- Methods of all imported classes that have a return type of this class.
-
getMethodThrowsDeclarationsWithTypeOfSelf
@PublicAPI(usage=ACCESS) public Set<ThrowsDeclaration<JavaMethod>> getMethodThrowsDeclarationsWithTypeOfSelf()- Returns:
ThrowsDeclarationsof all imported classes that have the type of this class.
-
getConstructorsWithParameterTypeOfSelf
- Returns:
- Constructors of all imported classes that have a parameter type of this class.
-
getConstructorsWithThrowsDeclarationTypeOfSelf
@PublicAPI(usage=ACCESS) public Set<ThrowsDeclaration<JavaConstructor>> getConstructorsWithThrowsDeclarationTypeOfSelf()- Returns:
ThrowsDeclarationsof all imported classes that have the type of this class.
-
getAnnotationsWithTypeOfSelf
- Returns:
- All imported
JavaAnnotationsthat have the annotation type of this class.
-
getAnnotationsWithParameterTypeOfSelf
- Returns:
- All imported
JavaAnnotationsthat have a parameter with type of this class.
-
getInstanceofChecksWithTypeOfSelf
- Returns:
- All imported
InstanceofChecksthat check if another class is an instance of this class.
-
isFullyImported
- Returns:
- Whether this class has been fully imported, including all dependencies.
Classes that are only transitively imported are not necessarily fully imported.
Suppose you only import a classFoothat calls a method of classBar. ThenBaris, as a dependency of the fully imported classFoo, only transitively imported.
-
isEquivalentTo
-
isAssignableFrom
-
isAssignableFrom
-
isAssignableFrom
@PublicAPI(usage=ACCESS) public boolean isAssignableFrom(DescribedPredicate<? super JavaClass> predicate) -
isAssignableTo
-
isAssignableTo
-
isAssignableTo
@PublicAPI(usage=ACCESS) public boolean isAssignableTo(DescribedPredicate<? super JavaClass> predicate) -
reflect
-
toString
-
getThrowsDeclarations
@PublicAPI(usage=ACCESS) public Set<ThrowsDeclaration<? extends JavaCodeUnit>> getThrowsDeclarations()- Returns:
- all throws declarations on any method or constructor of this class
(e.g.
void method() throws SomeException)
-