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 instanceof check
Note that a Dependency will by definition never be a self-reference, i.e. origin will never be equal to target.