Class ApplicationModules

java.lang.Object
org.springframework.modulith.core.ApplicationModules
All Implemented Interfaces:
Iterable<ApplicationModule>

public class ApplicationModules extends Object implements Iterable<ApplicationModule>
Author:
Oliver Drotbohm, Peter Gafert
  • Constructor Details

    • ApplicationModules

      protected ApplicationModules(ModulithMetadata metadata, Collection<String> packages, com.tngtech.archunit.base.DescribedPredicate<? super com.tngtech.archunit.core.domain.JavaClass> ignored, boolean useFullyQualifiedModuleNames, com.tngtech.archunit.core.importer.ImportOption option)
  • Method Details

    • of

      public static ApplicationModules of(Class<?> modulithType)
      Creates a new ApplicationModules relative to the given modulith type. Will inspect the Modulith annotation on the class given for advanced customizations of the module setup.
      Parameters:
      modulithType - must not be null.
      Returns:
      will never be null.
    • of

      public static ApplicationModules of(Class<?> modulithType, com.tngtech.archunit.base.DescribedPredicate<? super com.tngtech.archunit.core.domain.JavaClass> ignored)
      Creates a new ApplicationModules relative to the given modulith type, a ApplicationModuleDetectionStrategy and a DescribedPredicate which types and packages to ignore. Will inspect the Modulith and Modulithic annotations on the class given for advanced customizations of the module setup.
      Parameters:
      modulithType - must not be null.
      ignored - must not be null.
      Returns:
      will never be null.
    • of

      public static ApplicationModules of(String javaPackage)
      Creates a new ApplicationModules instance for the given package name.
      Parameters:
      javaPackage - must not be null or empty.
      Returns:
      will never be null.
    • of

      public static ApplicationModules of(String javaPackage, com.tngtech.archunit.base.DescribedPredicate<? super com.tngtech.archunit.core.domain.JavaClass> ignored)
      Creates a new ApplicationModules instance for the given package name and ignored classes.
      Parameters:
      javaPackage - must not be null or empty.
      ignored - must not be null.
      Returns:
      will never be null.
    • getModulithSource

      @Deprecated(forRemoval=true) public Object getModulithSource()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use getSource() instead
      Returns the source of the ApplicationModules. Either a main application class or a package name.
      Returns:
      will never be null.
    • getSource

      public Object getSource()
      Returns the source of the ApplicationModules. Either a main application class or a package name.
      Returns:
      will never be null.
    • getSharedModules

      public Set<ApplicationModule> getSharedModules()
      Returns all ApplicationModules registered as shared ones.
      Returns:
      will never be null.
    • contains

      public boolean contains(com.tngtech.archunit.core.domain.JavaClass type)
      Returns whether the given JavaClass is contained within the ApplicationModules.
      Parameters:
      type - must not be null.
    • contains

      public boolean contains(Class<?> type)
      Returns whether the given Class is contained within the ApplicationModules.
      Parameters:
      type - must not be null.
    • withinRootPackages

      public boolean withinRootPackages(String className)
      Returns whether the given type is contained in one of the root packages (not including sub-packages) of the modules.
      Parameters:
      className - must not be null or empty.
      Returns:
    • getModuleByName

      public Optional<ApplicationModule> getModuleByName(String name)
      Returns the ApplicationModule with the given name.
      Parameters:
      name - must not be null or empty.
      Returns:
    • getModuleByType

      public Optional<ApplicationModule> getModuleByType(com.tngtech.archunit.core.domain.JavaClass type)
      Returns the module that contains the given JavaClass.
      Parameters:
      type - must not be null.
      Returns:
    • getModuleByType

      public Optional<ApplicationModule> getModuleByType(String candidate)
      Returns the ApplicationModule containing the type with the given simple or fully-qualified name.
      Parameters:
      candidate - must not be null or empty.
      Returns:
      will never be null.
    • getModuleByType

      public Optional<ApplicationModule> getModuleByType(Class<?> candidate)
      Returns the ApplicationModule containing the given type.
      Parameters:
      candidate - must not be null.
      Returns:
      will never be null.
    • getModuleForPackage

      public Optional<ApplicationModule> getModuleForPackage(String name)
      Returns the ApplicationModule containing the given package.
      Parameters:
      name - must not be null or empty.
      Returns:
      will never be null.
    • verify

      public ApplicationModules verify()
      Execute all verifications to be applied, unless the verification has been executed before.
      Returns:
      will never be null.
    • detectViolations

      public Violations detectViolations()
      Executes all verifications to be applied and returns Violations if any occured. Will always execute the verifications in contrast to verify() which just runs once.
      Returns:
      will never be null.
      See Also:
    • stream

      public Stream<ApplicationModule> stream()
      Returns all ApplicationModules.
      Returns:
      will never be null.
    • getSystemName

      public Optional<String> getSystemName()
      Returns the system name if defined.
      Returns:
    • getComparator

      public Comparator<Object> getComparator()
      Returns a Comparator that will sort objects based on their types' application module. In other words, objects of types in more fundamental modules will be ordered before ones residing in downstream modules. For example, if module A depends on B, objects of types residing in B will be ordered before ones in A. For objects residing in the same module, standard Spring-based ordering (via Order or Ordered) will be applied.
      Returns:
      will never be null.
    • iterator

      public Iterator<ApplicationModule> iterator()
      Specified by:
      iterator in interface Iterable<ApplicationModule>
    • toString

      public String toString()
      Overrides:
      toString in class Object