Record Class Dependency
java.lang.Object
java.lang.Record
org.pgcodekeeper.core.dependencieslist.Dependency
- Record Components:
source- the dependent object (outgoing arrow)target- the object providing the dependency (incoming arrow)isStrong-truefor strong dependency,falsefor weak; defaults totruefor forward compatibility
public record Dependency(ObjectReference source, ObjectReference target, boolean isStrong)
extends Record
A record representing a directed dependency between two object references.
Interpreted as: source → target
(source depends on target).
A dependency can be either strong or weak:
- Strong dependency — the source cannot function without the target (e.g., composition, inheritance, required import)
- Weak dependency — the source may optionally use the target (e.g., observer, soft reference, suggested but not required)
This class does not validate the references nor guarantee that the dependency is acyclic — that is the responsibility of the calling code.
-
Constructor Summary
ConstructorsConstructorDescriptionDependency(ObjectReference source, ObjectReference target) Canonical constructor with isStrong defaulting totrue.Dependency(ObjectReference source, ObjectReference target, boolean isStrong) Creates an instance of aDependencyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisStrong()Returns the value of theisStrongrecord component.source()Returns the value of thesourcerecord component.target()Returns the value of thetargetrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Dependency
Canonical constructor with isStrong defaulting totrue.This constructor is provided for backward compatibility and convenience.
- Parameters:
source- the dependent objecttarget- the object being depended upon
-
Dependency
Creates an instance of aDependencyrecord class.
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-
target
Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-
isStrong
public boolean isStrong()Returns the value of theisStrongrecord component.- Returns:
- the value of the
isStrongrecord component
-