Interface ModulesByAnnotationShould<ANNOTATION extends Annotation>

All Superinterfaces:
ModulesShould<AnnotationDescriptor<ANNOTATION>>

@PublicAPI(usage=ACCESS, state=EXPERIMENTAL) public interface ModulesByAnnotationShould<ANNOTATION extends Annotation> extends ModulesShould<AnnotationDescriptor<ANNOTATION>>
  • Method Details

    • respectTheirAllowedDependenciesDeclaredIn

      @PublicAPI(usage=ACCESS, state=EXPERIMENTAL) ModulesByAnnotationRule<ANNOTATION> respectTheirAllowedDependenciesDeclaredIn(String annotationPropertyName, ModuleDependencyScope dependencyScope)
      Like ModulesShould.respectTheirAllowedDependencies(DescribedPredicate, ModuleDependencyScope), but the allowed dependencies will be automatically derived from the ModulesByAnnotationShould property named annotationPropertyName. This property *must* be of type String[] and contain the names of the ArchModules to which access is allowed.

      For example, given the user-defined annotation
      
       @interface MyModule {
         String name();
      
         String[] allowedDependencies() default {};
       }
       
      and the annotated root classes
      
       @MyModule(name = "Module One", allowedDependencies = {"Module Two", "Module Three"})
       interface ModuleOneDescriptor {}
      
       @MyModule(name = "Module Two", allowedDependencies = {"Module Three"})
       interface ModuleTwoDescriptor {}
      
       @MyModule(name = "Module Three")
       interface ModuleThreeDescriptor {}
       
      Then the allowed dependencies between the modules would be
      
       ,----------.
       |Module One| ------------.
       `----------'              \
            |                    |
            |                    |
            v                    v
       ,----------.         ,------------.
       |Module Two| ------> |Module Three|
       `----------'         `------------'
       
      Parameters:
      annotationPropertyName - The name of the property declared within ModulesByAnnotationShould that declares allowed dependencies to other ArchModules by name
      dependencyScope - Allows to adjust which dependencies are considered relevant by the rule
      Returns:
      An ArchRule to be checked against a set of JavaClasses
    • onlyDependOnEachOtherThroughPackagesDeclaredIn

      @PublicAPI(usage=ACCESS, state=EXPERIMENTAL) ModulesByAnnotationRule<ANNOTATION> onlyDependOnEachOtherThroughPackagesDeclaredIn(String annotationPropertyName)
      Checks that the target classes of each Dependency that originate from one ArchModule and target another ArchModule reside in a package that matches a package identifier declared within ModulesByAnnotationShould.

      For example, given the annotation
      
       @interface MyModule {
         String name();
      
         String[] exposedPackages() default {};
       }
       
      and the annotated root classes
      
       @MyModule(name = "Module One")
       interface ModuleOneDescriptor {}
      
       @MyModule(name = "Module Two", exposedPackages = {"com.myapp.module_two.api.."})
       interface ModuleTwoDescriptor {}
       
      Then a dependency from Module One to a class com.myapp.module_two.api.SomeApi would be allowed, but a dependency to a class com.myapp.module_two.OutsideOfApi would be forbidden.
      Parameters:
      annotationPropertyName - The name of the property declared within ModulesByAnnotationShould that defines through which package identifiers modules may depend on each other
      Returns:
      An ArchRule to be checked against a set of JavaClasses