Interface ModulesRule<DESCRIPTOR extends ArchModule.Descriptor>
- All Superinterfaces:
ArchRule,CanBeEvaluated,CanOverrideDescription<ArchRule>,HasDescription,ModulesShouldConjunction<DESCRIPTOR>
- All Known Subinterfaces:
ModulesByAnnotationRule<ANNOTATION>
@PublicAPI(usage=ACCESS,
state=EXPERIMENTAL)
public interface ModulesRule<DESCRIPTOR extends ArchModule.Descriptor>
extends ArchRule, ModulesShouldConjunction<DESCRIPTOR>
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tngtech.archunit.lang.ArchRule
ArchRule.Assertions, ArchRule.Factory, ArchRule.Transformation -
Method Summary
Modifier and TypeMethodDescriptionallowEmptyShould(boolean allowEmptyShould) If set totrueallows the should-clause of this rule to be checked against an empty set of elements.Allows to adjust the description of this object.ignoreDependency(Class<?> origin, Class<?> target) Ignores all class dependencies from the given origin class to the given target class.ignoreDependency(String originFullyQualifiedClassName, String targetFullyQualifiedClassName) Ignores all class dependencies from the origin class with the given fully qualified origin class name to the target class with the given fully qualified target class name.ignoreDependency(Predicate<? super Dependency> dependencyPredicate) Ignores all class dependencies matching the given predicate.ignoreDependency(Predicate<? super JavaClass> originPredicate, Predicate<? super JavaClass> targetPredicate) Ignores all class dependencies from any origin class matching the given origin class predicate to any target class matching the given target class predicate.Methods inherited from interface com.tngtech.archunit.lang.CanBeEvaluated
evaluateMethods inherited from interface com.tngtech.archunit.base.HasDescription
getDescriptionMethods inherited from interface com.tngtech.archunit.library.modules.syntax.ModulesShouldConjunction
andShould, andShould
-
Method Details
-
as
Description copied from interface:CanOverrideDescriptionAllows to adjust the description of this object. Note that this method will not modify the current object, but instead return a new object with adjusted description.- Specified by:
asin interfaceCanOverrideDescription<DESCRIPTOR extends ArchModule.Descriptor>- Parameters:
newDescription- The description the result of this method will hold- Returns:
- A new equivalent object with adjusted description
-
because
-
allowEmptyShould
@PublicAPI(usage=ACCESS, state=EXPERIMENTAL) ModulesRule<DESCRIPTOR> allowEmptyShould(boolean allowEmptyShould) Description copied from interface:ArchRuleIf set totrueallows the should-clause of this rule to be checked against an empty set of elements. Otherwise, the rule will fail with a respective message. This is to prevent possible implementation errors, like filtering for a non-existing package in the that-clause causing an always-passing rule.
Note that this method will override the configuration propertyarchRule.failOnEmptyShould.- Specified by:
allowEmptyShouldin interfaceArchRule- Parameters:
allowEmptyShould- Whether the rule fails if the should-clause is evaluated with an empty set of elements- Returns:
- A (new)
ArchRulewith adjustedallowEmptyShouldbehavior
-
ignoreDependency
@PublicAPI(usage=ACCESS, state=EXPERIMENTAL) ModulesRule<DESCRIPTOR> ignoreDependency(Class<?> origin, Class<?> target) Ignores all class dependencies from the given origin class to the given target class.
Note that this will always refer to the lastArchConditiononly if multipleArchConditions are joined usingModulesShouldConjunction.andShould(). E.g.modules()... .should().firstCondition() .ignoreDependency(/* will only refer to `firstCondition`, not to `secondCondition` */) .andShould().secondCondition() .ignoreDependency(/* will only refer to `secondCondition`, not to `firstCondition` */)- Parameters:
origin- the origin class of dependencies to ignoretarget- the target class of dependencies to ignore
-
ignoreDependency
@PublicAPI(usage=ACCESS, state=EXPERIMENTAL) ModulesRule<DESCRIPTOR> ignoreDependency(String originFullyQualifiedClassName, String targetFullyQualifiedClassName) Ignores all class dependencies from the origin class with the given fully qualified origin class name to the target class with the given fully qualified target class name.
Note that this will always refer to the lastArchConditiononly if multipleArchConditions are joined usingModulesShouldConjunction.andShould(). E.g.modules()... .should().firstCondition() .ignoreDependency(/* will only refer to `firstCondition`, not to `secondCondition` */) .andShould().secondCondition() .ignoreDependency(/* will only refer to `secondCondition`, not to `firstCondition` */)- Parameters:
originFullyQualifiedClassName- the fully qualified origin class of dependencies to ignoretargetFullyQualifiedClassName- the fully qualified target class of dependencies to ignore
-
ignoreDependency
@PublicAPI(usage=ACCESS, state=EXPERIMENTAL) ModulesRule<DESCRIPTOR> ignoreDependency(Predicate<? super JavaClass> originPredicate, Predicate<? super JavaClass> targetPredicate) Ignores all class dependencies from any origin class matching the given origin class predicate to any target class matching the given target class predicate.
Note that this will always refer to the lastArchConditiononly if multipleArchConditions are joined usingModulesShouldConjunction.andShould(). E.g.modules()... .should().firstCondition() .ignoreDependency(/* will only refer to `firstCondition`, not to `secondCondition` */) .andShould().secondCondition() .ignoreDependency(/* will only refer to `secondCondition`, not to `firstCondition` */)- Parameters:
originPredicate- predicate determining for which origins of dependencies the dependency should be ignoredtargetPredicate- predicate determining for which targets of dependencies the dependency should be ignored
-
ignoreDependency
@PublicAPI(usage=ACCESS, state=EXPERIMENTAL) ModulesRule<DESCRIPTOR> ignoreDependency(Predicate<? super Dependency> dependencyPredicate) Ignores all class dependencies matching the given predicate.
Note that this will always refer to the lastArchConditiononly if multipleArchConditions are joined usingModulesShouldConjunction.andShould(). E.g.modules()... .should().firstCondition() .ignoreDependency(/* will only refer to `firstCondition`, not to `secondCondition` */) .andShould().secondCondition() .ignoreDependency(/* will only refer to `secondCondition`, not to `firstCondition` */)
-