Interface ModulesShould<DESCRIPTOR extends ArchModule.Descriptor>
- All Known Subinterfaces:
ModulesByAnnotationShould<ANNOTATION>
@PublicAPI(usage=ACCESS,
state=EXPERIMENTAL)
public interface ModulesShould<DESCRIPTOR extends ArchModule.Descriptor>
-
Method Summary
Modifier and TypeMethodDescriptionChecks that theArchModules under consideration don't have any cyclic dependencies within theirmodule dependencies.LikeonlyDependOnEachOtherThroughClassesThat(DescribedPredicate)but allows to specify the predicate in a fluent way.onlyDependOnEachOtherThroughClassesThat(DescribedPredicate<? super JavaClass> predicate) Checks that thetarget classesof eachDependencythat originate from oneArchModuleand target anotherArchModulesatisfy the passedpredicate.respectTheirAllowedDependencies(DescribedPredicate<? super ModuleDependency<DESCRIPTOR>> allowedDependencyPredicate, ModuleDependencyScope dependencyScope) Creates a rule to check that theArchModules under consideration don't have any forbiddenmodule dependenciesaccording to the passedallowedDependencyPredicate.respectTheirAllowedDependencies(AllowedModuleDependencies allowedDependencies, ModuleDependencyScope dependencyScope) Convenience API forrespectTheirAllowedDependencies(DescribedPredicate, ModuleDependencyScope)that allows to statically define whichmodulesmay depend on which othermodulesbymodule name.
-
Method Details
-
respectTheirAllowedDependencies
@PublicAPI(usage=ACCESS, state=EXPERIMENTAL) ModulesRule<DESCRIPTOR> respectTheirAllowedDependencies(DescribedPredicate<? super ModuleDependency<DESCRIPTOR>> allowedDependencyPredicate, ModuleDependencyScope dependencyScope) Creates a rule to check that theArchModules under consideration don't have any forbiddenmodule dependenciesaccording to the passedallowedDependencyPredicate. It is possible to adjust whichclass dependenciesthe rule considers relevant by the passeddependencyScope.- Parameters:
allowedDependencyPredicate- Decides whichmodule dependenciesare allowed. If theDescribedPredicatereturnstruethe dependency is allowed, otherwise it is forbidden.dependencyScope- Allows to adjust whichdependenciesare considered relevant by the rule- Returns:
- An
ArchRuleto be checked against a set ofJavaClasses
-
respectTheirAllowedDependencies
@PublicAPI(usage=ACCESS, state=EXPERIMENTAL) ModulesRule<DESCRIPTOR> respectTheirAllowedDependencies(AllowedModuleDependencies allowedDependencies, ModuleDependencyScope dependencyScope) Convenience API forrespectTheirAllowedDependencies(DescribedPredicate, ModuleDependencyScope)that allows to statically define whichmodulesmay depend on which othermodulesbymodule name.
Example:modules() .definedByPackages("..example.(*)..") .should().respectTheirAllowedDependencies( AllowedModuleDependencies.allow() .fromModule("Module One").toModules("Module Three", "Module Four") .fromModule("Module Two").toModules("Module Four"), consideringOnlyDependenciesInAnyPackage("..example..")); -
onlyDependOnEachOtherThroughClassesThat
@PublicAPI(usage=ACCESS, state=EXPERIMENTAL) ModulesRule<DESCRIPTOR> onlyDependOnEachOtherThroughClassesThat(DescribedPredicate<? super JavaClass> predicate) Checks that thetarget classesof eachDependencythat originate from oneArchModuleand target anotherArchModulesatisfy the passedpredicate.- Parameters:
predicate- ADescribedPredicateto determine whichtarget classesofdependenciesare allowed.- Returns:
- An
ArchRuleto be checked against a set ofJavaClasses
-
onlyDependOnEachOtherThroughClassesThat
@PublicAPI(usage=ACCESS, state=EXPERIMENTAL) ClassesThat<ModulesRule<DESCRIPTOR>> onlyDependOnEachOtherThroughClassesThat()LikeonlyDependOnEachOtherThroughClassesThat(DescribedPredicate)but allows to specify the predicate in a fluent way. -
beFreeOfCycles
Checks that theArchModules under consideration don't have any cyclic dependencies within theirmodule dependencies.- Returns:
- An
ArchRuleto be checked against a set ofJavaClasses
-