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
Modifier and TypeClassDescriptionstatic final class
static final class
Predefinedpredicates
targetingJavaClass
.Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.CanBeAnnotated
CanBeAnnotated.Utils
Nested 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<?>>
<A extends Annotation>
AgetAnnotationOfType
(Class<A> type) getAnnotationOfType
(String typeName) Set<JavaAnnotation<?>>
Set<JavaAnnotation<?>>
The base component type is the class'component type
if 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 enclosingJavaCodeUnit
if 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.boolean
isAnnotatedWith
(DescribedPredicate<? super JavaAnnotation<?>> predicate) Returnstrue
, if this element is annotated with an annotation matching the given predicate.boolean
isAnnotatedWith
(Class<? extends Annotation> annotationType) Returnstrue
, if this element is annotated with the given annotation type.boolean
isAnnotatedWith
(String annotationTypeName) boolean
boolean
An anonymous class is an inner class that is automatically derived from a class creation expression with a declared class body, e.g.boolean
isArray()
boolean
isAssignableFrom
(DescribedPredicate<? super JavaClass> predicate) boolean
isAssignableFrom
(Class<?> type) boolean
isAssignableFrom
(String typeName) boolean
isAssignableTo
(DescribedPredicate<? super JavaClass> predicate) boolean
isAssignableTo
(Class<?> type) boolean
isAssignableTo
(String typeName) boolean
isEnum()
boolean
isEquivalentTo
(Class<?> clazz) boolean
boolean
An inner class is a nested class that is not explicitly or implicitly declared static.
Example:boolean
boolean
A local class is a nested class that is not a member of any class and that has a name.
Example:boolean
A member class is a class whose declaration is directly enclosed in the body of another class or interface declaration.
Example:boolean
isMetaAnnotatedWith
(DescribedPredicate<? super JavaAnnotation<?>> predicate) Returnstrue
, if this element is meta-annotated with an annotation matching the given predicate.boolean
isMetaAnnotatedWith
(Class<? extends Annotation> type) Returnstrue
, if this element is meta-annotated with the given annotation type.boolean
isMetaAnnotatedWith
(String typeName) boolean
A nested class is any class whose declaration occurs within the body of another class or interface.
Example:boolean
boolean
isRecord()
Returns whether this class is a record according to the Java Language Specification.boolean
A top level class is a class that is not a nested class, i.e.Class<?>
reflect()
Converts thisJavaType
into 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:
getSourceCodeLocation
in interfaceHasSourceCodeLocation
- Returns:
- The
SourceCodeLocation
of this object, i.e. how to locate the respective object within the set of source files.
-
getDescription
- Specified by:
getDescription
in interfaceHasDescription
-
getName
- Specified by:
getName
in interfaceHasName
- Returns:
- The fully qualified name of this
JavaClass
, compareClass.getName()
of the Reflection API
-
getFullName
- Specified by:
getFullName
in 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 type
if 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() {} } }
TopLevel
is a top level class, since all other classes are declared within the body ofTopLevel
and are thereby nested classes.
Compare e.g. Java Language Specification- Returns:
true
if this class is a top level class, i.e. not nested inside of any other class,false
otherwise- 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
,NestedLocal
and 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.TopLevel
on the other side is no nested class.
Compare e.g. Java Language Specification- Returns:
true
if this class is nested, i.e. declared within another class,false
otherwise (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() {} } }
MemberClassNonStatic
andMemberClassStatic
are member classes, since they are directly declared within the body ofTopLevel
. On the other handNoMemberLocal
and the class the compiler creates for the anonymous class derived from"new NoMemberAnonymous() {}"
(which will have some generated name likeTopLevel$1
), as well asTopLevel
itself, are not considered member classes.
Compare e.g. Java Language Specification- Returns:
true
if this class is a member class, i.e. directly declared within the body of another class,false
otherwise- 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
,InnerLocalClass
and 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
,NoInnerClassSinceInterface
andTopLevel
are no inner classes, because the former two explicitly or implicitly have thestatic
modifier while the latter one is a top level class.
Compare e.g. Java Language Specification- Returns:
true
if this class is an inner class (i.e. nested but non-static)false
otherwise- 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() {} } }
LocalClass
is 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
,NestedStaticClass
and 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 ofTopLevel
or are anonymous and thus have no name.
Compare e.g. Java Language Specification- Returns:
true
if this class is local class,false
otherwise- 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
, whereSomeClass
is 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
,NestedStaticClass
andLocalClass
are considered non-anonymous.
Compare e.g. Java Language Specification- Returns:
true
if this class is an anonymous class,false
otherwise- See Also:
-
getModifiers
- Specified by:
getModifiers
in interfaceHasModifiers
-
isAnnotatedWith
Description copied from interface:CanBeAnnotated
Returnstrue
, if this element is annotated with the given annotation type.- Specified by:
isAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
annotationType
- The type of the annotation to check for
-
isAnnotatedWith
- Specified by:
isAnnotatedWith
in 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:CanBeAnnotated
Returnstrue
, if this element is annotated with an annotation matching the given predicate.- Specified by:
isAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
predicate
- Qualifies matching annotations
-
isMetaAnnotatedWith
Description copied from interface:CanBeAnnotated
Returnstrue
, 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
true
if this element is directly annotated with the given annotation type.- Specified by:
isMetaAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
type
- The type of the annotation to check for
-
isMetaAnnotatedWith
- Specified by:
isMetaAnnotatedWith
in 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:CanBeAnnotated
Returnstrue
, 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
true
if this element is directly annotated with an annotation matching the given predicate.- Specified by:
isMetaAnnotatedWith
in interfaceCanBeAnnotated
- Parameters:
predicate
- Qualifies matching annotations
-
getAnnotationOfType
- Specified by:
getAnnotationOfType
in interfaceHasAnnotations<JavaClass>
- Type Parameters:
A
- The type of theAnnotation
to retrieve- Parameters:
type
- A given annotation type to matchJavaAnnotations
against- Returns:
- An
Annotation
of the given annotation type - Throws:
IllegalArgumentException
- if the class is not annotated with the given type- See Also:
-
getAnnotationOfType
- Specified by:
getAnnotationOfType
in interfaceHasAnnotations<JavaClass>
- Parameters:
typeName
- The fully qualified class name of theAnnotation
type to retrieve.- Returns:
- The
JavaAnnotation
matching the given type. Will throw anIllegalArgumentException
if no matchingAnnotation
is present. - See Also:
-
getAnnotations
- Specified by:
getAnnotations
in interfaceHasAnnotations<JavaClass>
-
tryGetAnnotationOfType
@PublicAPI(usage=ACCESS) public <A extends Annotation> Optional<A> tryGetAnnotationOfType(Class<A> type) - Specified by:
tryGetAnnotationOfType
in interfaceHasAnnotations<JavaClass>
- Type Parameters:
A
- The type of theAnnotation
to retrieve- Parameters:
type
- A given annotation type to matchJavaAnnotations
against- Returns:
- An
Optional
containing anAnnotation
of 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:
tryGetAnnotationOfType
in interfaceHasAnnotations<JavaClass>
- Parameters:
typeName
- The fully qualified class name of theAnnotation
type to retrieve.- Returns:
- The
JavaAnnotation
matching the given type orOptional.empty()
if there is noAnnotation
with the respective annotation type. - See Also:
-
getTypeParameters
- Specified by:
getTypeParameters
in 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:JavaType
Converts thisJavaType
into the erased type (compare the Java Language Specification). In particular this will result in- the class itself, if this type is a
JavaClass
- the
JavaClass
equivalent toObject
, if this type is an unboundJavaTypeVariable
- the
JavaClass
equivalent to the erasure of the left most bound, if this type is a boundJavaTypeVariable
- if this type is a
JavaGenericArrayType
, the erasure will be theJavaClass
equivalent 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[][]
whereT
is unbound, then the erasure will be the array typeObject[][]
- the class itself, if this type is a
-
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 enclosingJavaCodeUnit
if 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 theJavaConstructor
OuterClass()
andLocalClass.
getEnclosingCodeUnit()
would return theJavaMethod
void 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_NAME
orSTATIC_INITIALIZER_NAME
parameters
- The parameter signature of the method specified asClass
Objects- 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
String
name andint
ordinal 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
method
orconstructor 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:
ThrowsDeclarations
of 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:
ThrowsDeclarations
of all imported classes that have the type of this class.
-
getAnnotationsWithTypeOfSelf
- Returns:
- All imported
JavaAnnotations
that have the annotation type of this class.
-
getAnnotationsWithParameterTypeOfSelf
- Returns:
- All imported
JavaAnnotations
that have a parameter with type of this class.
-
getInstanceofChecksWithTypeOfSelf
- Returns:
- All imported
InstanceofChecks
that 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 classFoo
that calls a method of classBar
. ThenBar
is, 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
)
-