Package com.tngtech.archunit.core.domain
Class Dependency
java.lang.Object
com.tngtech.archunit.core.domain.Dependency
- All Implemented Interfaces:
HasDescription,HasSourceCodeLocation,Comparable<Dependency>
@PublicAPI(usage=ACCESS)
public final class Dependency
extends Object
implements HasDescription, Comparable<Dependency>, HasSourceCodeLocation
Represents a dependency of one Java class on another Java class. Such a dependency can occur by either of the
following:
- a class accesses a field of another class
- a class calls a method/constructor of another class
- a class inherits from another class
- a class implements an interface
- a class has a field with type of another class
- a class has a method/constructor with parameter/return type of another class
- a class (or method/constructor of this class) declares a type parameter referencing another class
- a class (or method/constructor of this class) is annotated with an annotation of a certain type or referencing another class as annotation parameter
- a method/constructor of a class references another class in a throws declaration
- a class references another class object (e.g.
Example.class) - a class references another class in an
instanceofcheck
Dependency will by definition never be a self-reference,
i.e. origin will never be equal to target.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classPredefinedfunctionsto transformDependency.static final classPredefinedpredicatestargetingDependency. -
Method Summary
Modifier and TypeMethodDescriptionintbooleaninthashCode()toString()static JavaClassestoTargetClasses(Iterable<Dependency> dependencies)
-
Method Details
-
getOriginClass
- Returns:
- The class where this dependency originates from (e.g. because the origin class calls a method of another class)
-
getTargetClass
- Returns:
- The class that is targeted by this dependency (e.g. because it contains a method that is called from another class)
-
getDescription
- Specified by:
getDescriptionin interfaceHasDescription
-
getSourceCodeLocation
- Specified by:
getSourceCodeLocationin interfaceHasSourceCodeLocation- Returns:
- The
SourceCodeLocationof this object, i.e. how to locate the respective object within the set of source files.
-
compareTo
- Specified by:
compareToin interfaceComparable<Dependency>
-
hashCode
public int hashCode() -
equals
-
toString
-
toTargetClasses
@PublicAPI(usage=ACCESS) public static JavaClasses toTargetClasses(Iterable<Dependency> dependencies)
-