Class AbstractDependency
java.lang.Object
me.datafox.dfxengine.dependencies.AbstractDependency
- All Implemented Interfaces:
Dependency
- Direct Known Subclasses:
DependencyDependent
A class with values that values of other classes depend on. A class with values depending on the implementing class
should implement Dependent, and all dependencies should be added to the class implementing this interface
with addDependent(Dependent) or addDependents(Collection). The implementation of these methods
must check for cyclic dependencies and throw IllegalArgumentException if one would be caused by the
operation.
The cyclic dependency detection in this class will only detect dependent dependencies that implement both
Dependency and Dependent. It is recommended to extend DependencyDependent where possible for
all cases where both interfaces would be implemented.
-
Field Summary
FieldsModifier and TypeFieldDescriptionSet ofDependenciesfor this dependent.protected final org.slf4j.LoggerLoggerfor this dependent. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddDependent(Dependent dependent) Register aDependentthat depends on this class.booleanaddDependents(Collection<? extends Dependent> dependents) RegisterDependentsthat depends on this class.booleancontainsDependent(Dependent dependent) booleancontainsDependentRecursive(Dependent dependent) Checks if the specifiedDependentis registered to this class or any of its dependents that also implement dependent, recursively.booleancontainsDependents(Collection<? extends Dependent> dependents) booleancontainsDependentsRecursive(Collection<? extends Dependent> dependents) Checks if all the specifiedDependentsare registered to this class or any of its dependencies that also implement dependent, recursively.voidCallsDependent.invalidate()on allDependentsof this class.booleanremoveDependent(Dependent dependent) booleanremoveDependents(Collection<? extends Dependent> dependents)
-
Field Details
-
logger
protected final org.slf4j.Logger loggerLoggerfor this dependent. -
dependents
Set ofDependenciesfor this dependent.
-
-
Constructor Details
-
AbstractDependency
protected AbstractDependency(org.slf4j.Logger logger) - Parameters:
logger-Loggerfor this dependent
-
-
Method Details
-
getDependents
- Specified by:
getDependentsin interfaceDependency- Returns:
- all
Dependentsthat depend on this class
-
invalidateDependents
public void invalidateDependents()CallsDependent.invalidate()on allDependentsof this class.- Specified by:
invalidateDependentsin interfaceDependency
-
addDependent
Register aDependentthat depends on this class. The method must check for cyclic dependencies and throwIllegalArgumentExceptionif one is detected.- Specified by:
addDependentin interfaceDependency- Parameters:
dependent-Dependentthat depends on this class- Returns:
trueif the registeredDependentschanged as a result of this operation- Throws:
IllegalArgumentException- if this operation would cause a cyclic dependency
-
addDependents
RegisterDependentsthat depends on this class. The method must check for cyclic dependencies and throwIllegalArgumentExceptionif one is detected.- Specified by:
addDependentsin interfaceDependency- Parameters:
dependents-Dependenciesthat depend on this class- Returns:
trueif the registeredDependentschanged as a result of this operation- Throws:
IllegalArgumentException- if this operation would cause a cyclic dependency
-
removeDependent
- Specified by:
removeDependentin interfaceDependency- Parameters:
dependent-Dependentto be removed- Returns:
trueif the registeredDependentschanged as a result of this operation
-
removeDependents
- Specified by:
removeDependentsin interfaceDependency- Parameters:
dependents-Dependentsto be removed- Returns:
trueif the registeredDependentschanged as a result of this operation
-
containsDependent
- Specified by:
containsDependentin interfaceDependency- Parameters:
dependent-Dependentto be checked for- Returns:
trueif the specifiedDependentis registered to this class
-
containsDependents
- Specified by:
containsDependentsin interfaceDependency- Parameters:
dependents-Dependentsto be checked for- Returns:
trueif all the specifiedDependentsare registered to this class
-
containsDependentRecursive
Checks if the specifiedDependentis registered to this class or any of its dependents that also implement dependent, recursively. In practice any dependent that depends on this class, directly or indirectly, would cause this method to returntrue.- Specified by:
containsDependentRecursivein interfaceDependency- Parameters:
dependent-Dependentto be checked for- Returns:
trueif the specifiedDependentis registered to this class or any of its dependents that also implement dependent, recursively
-
containsDependentsRecursive
Checks if all the specifiedDependentsare registered to this class or any of its dependencies that also implement dependent, recursively. In practice any collection of dependencies that depend on this class, directly or indirectly, would cause this method to returntrue.- Specified by:
containsDependentsRecursivein interfaceDependency- Parameters:
dependents-Dependenciesto be checked for- Returns:
trueif the specifiedDependenciesare registered to this class or any of its dependencies that also implement dependent, recursively
-
dependentStream
- Specified by:
dependentStreamin interfaceDependency- Returns:
Streamof allDependentsthat are registered to this class
-
recursiveDependentStream
- Specified by:
recursiveDependentStreamin interfaceDependency- Returns:
Streamof allDependentsthat are registered to this class or any of its dependents that also implement dependency, recursively
-