Interface ClassesShouldConjunction
- All Superinterfaces:
ArchRule,CanBeEvaluated,CanOverrideDescription<ArchRule>,HasDescription
Allows to join together any existing
Thus, for more complex conditions please consider explicitly joining
ArchCondition of this rule with another ArchCondition
via and or or. Note that the behavior is always fully left-associative, i.e. there is no
"operator precedence" as for && or ||. Take for example
classes()...should().bePublic().orShould().bePrivate().andShould().haveNameMatching(pattern)
The semantics of the new condition will be (public OR private) AND haveNameMatching
– and not public || (private && haveNameMatching).
Thus, for more complex conditions please consider explicitly joining
preconfigured conditions
or custom conditions via ArchCondition.and(ArchCondition) and ArchCondition.or(ArchCondition)
where you can freely control the precedence via nesting. E.g.
classes()...should(
bePublic().or(
bePrivate().and(haveNameMatching(pattern))
)
)
Note that inverting the rule, e.g. via ArchRuleDefinition.noClasses(), will also invert the join operator. I.e.
if you define noClasses().should().a().orShould().b() it will mean that all classes must satisfy not(a) AND not(b).-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tngtech.archunit.lang.ArchRule
ArchRule.Assertions, ArchRule.Factory, ArchRule.Transformation -
Method Summary
Modifier and TypeMethodDescriptionLikeandShould(ArchCondition)but offers a fluent API to pick the condition to join.andShould(ArchCondition<? super JavaClass> condition) Joins another condition to this rule withandsemantics.orShould()LikeorShould(ArchCondition)but offers a fluent API to pick the condition to join.orShould(ArchCondition<? super JavaClass> condition) Joins another condition to this rule withorsemantics.Methods inherited from interface com.tngtech.archunit.lang.ArchRule
allowEmptyShould, because, checkMethods inherited from interface com.tngtech.archunit.lang.CanBeEvaluated
evaluateMethods inherited from interface com.tngtech.archunit.core.domain.properties.CanOverrideDescription
asMethods inherited from interface com.tngtech.archunit.base.HasDescription
getDescription
-
Method Details
-
andShould
@PublicAPI(usage=ACCESS) ClassesShouldConjunction andShould(ArchCondition<? super JavaClass> condition) Joins another condition to this rule withandsemantics. That is, all classes under test now needs to satisfy the existing condition and this new one.
Note that this is always left-associative and does not support any operator precedence, seeClassesShouldConjunction.- Parameters:
condition- Another condition to be 'and'-ed to the current condition of this rule- Returns:
- A syntax element, which can be used to further restrict the classes under consideration
-
andShould
LikeandShould(ArchCondition)but offers a fluent API to pick the condition to join. -
orShould
@PublicAPI(usage=ACCESS) ClassesShouldConjunction orShould(ArchCondition<? super JavaClass> condition) Joins another condition to this rule withorsemantics. That is, all classes under test now needs to satisfy the existing condition or this given one.
Note that this is always left-associative and does not support any operator precedence, seeClassesShouldConjunction.- Parameters:
condition- Another condition to be 'and'-ed to the current condition of this rule- Returns:
- A syntax element, which can be used to further restrict the classes under consideration
-
orShould
LikeorShould(ArchCondition)but offers a fluent API to pick the condition to join.
-