Class ApplicationModule

java.lang.Object
org.springframework.modulith.core.ApplicationModule

public class ApplicationModule extends Object
An application module.
Author:
Oliver Drotbohm
  • Constructor Details

    • ApplicationModule

      ApplicationModule(JavaPackage basePackage, boolean useFullyQualifiedModuleNames)
      Creates a new ApplicationModule for the given base package and whether to use fully-qualified module names.
      Parameters:
      basePackage - must not be null.
      useFullyQualifiedModuleNames -
  • Method Details

    • getBasePackage

      public JavaPackage getBasePackage()
      Returns the module's base package.
      Returns:
      the basePackage
    • getNamedInterfaces

      public NamedInterfaces getNamedInterfaces()
      Returns all NamedInterfaces exposed by the module.
      Returns:
      the namedInterfaces will never be null.
    • getName

      public String getName()
      Returns the logical name of the module.
      Returns:
      will never be null or empty.
    • getDisplayName

      public String getDisplayName()
      Returns the name of the ApplicationModule for display purposes.
      Returns:
      will never be null or empty.
    • getDependencies

      public ApplicationModuleDependencies getDependencies(ApplicationModules modules, DependencyType... type)
      Parameters:
      modules - must not be null.
      type - must not be null.
      Returns:
      will never be null.
    • getEventsListenedTo

      public List<com.tngtech.archunit.core.domain.JavaClass> getEventsListenedTo(ApplicationModules modules)
      Returns all event types the current module exposes an event listener for.
      Parameters:
      modules - must not be null.
      Returns:
    • getPublishedEvents

      public List<EventType> getPublishedEvents()
      Returns all EventTypes published by the module.
      Returns:
      will never be null.
    • getValueTypes

      public List<com.tngtech.archunit.core.domain.JavaClass> getValueTypes()
      Returns all value types contained in the module.
      Returns:
      will never be null.
    • getAggregateRoots

      public List<com.tngtech.archunit.core.domain.JavaClass> getAggregateRoots()
      Returns all types that are considered aggregate roots.
      Returns:
      will never be null.
    • getBootstrapDependencies

      public Stream<ApplicationModule> getBootstrapDependencies(ApplicationModules modules)
      Returns all modules that contain types which the types of the current module depend on.
      Parameters:
      modules - must not be null.
      Returns:
    • getBootstrapDependencies

      public Stream<ApplicationModule> getBootstrapDependencies(ApplicationModules modules, DependencyDepth depth)
    • getBootstrapBasePackages

      public Stream<JavaPackage> getBootstrapBasePackages(ApplicationModules modules, DependencyDepth depth)
      Returns all JavaPackage for the current module including the ones by its dependencies.
      Parameters:
      modules - must not be null.
      depth - must not be null.
      Returns:
    • getSpringBeans

      public List<SpringBean> getSpringBeans()
      Returns all SpringBeans contained in the module.
      Returns:
      will never be null.
    • getArchitecturallyEvidentType

      public ArchitecturallyEvidentType getArchitecturallyEvidentType(Class<?> type)
      Returns the ArchitecturallyEvidentType for the given type.
      Parameters:
      type - must not be null.
      Returns:
      will never be null.
      Throws:
      IllegalArgumentException - if the given type is not a module type.
    • contains

      public boolean contains(com.tngtech.archunit.core.domain.JavaClass type)
    • contains

      public boolean contains(@Nullable Class<?> type)
    • getType

      public Optional<com.tngtech.archunit.core.domain.JavaClass> getType(String candidate)
      Returns the JavaClass for the given candidate simple of fully-qualified type name.
      Parameters:
      candidate - must not be null or empty.
      Returns:
      will never be null.
    • isExposed

      public boolean isExposed(com.tngtech.archunit.core.domain.JavaClass type)
      Returns whether the given JavaClass is exposed by the current module, i.e. whether it's part of any of the module's named interfaces.
      Parameters:
      type - must not be null.
      Returns:
    • verifyDependencies

      public void verifyDependencies(ApplicationModules modules)
    • detectDependencies

      public Violations detectDependencies(ApplicationModules modules)
    • isRootModule

      public boolean isRootModule()
      Returns whether the module is considered a root one, i.e., it is an artificial one created for each base package configured.
      Returns:
      whether the module is considered a root one.
      Since:
      1.1
    • hasBasePackage

      boolean hasBasePackage(String candidate)
      Returns whether the module has a base package with the given name.
      Parameters:
      candidate - must not be null or empty.
      Returns:
      whether the module has a base package with the given name.
      Since:
      1.1
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(@Nullable ApplicationModules modules)
    • getSpringBeansInternal

      Classes getSpringBeansInternal()
    • getDeclaredDependencies

      Returns all declared module dependencies, either explicitly declared or defined as shared on the given ApplicationModules instance.
      Parameters:
      modules - must not be null.
      Returns:
    • contains

      boolean contains(String candidate)
      Returns whether the given module contains a type with the given simple or fully qualified name.
      Parameters:
      candidate - must not be null or empty.
      Returns:
    • containsPackage

      boolean containsPackage(String packageName)
      Returns whether the ApplicationModule contains the package with the given name, which means the given package is either the module's base package or a sub package of it.
      Parameters:
      packageName - must not be null or empty.
      Returns:
      whether the ApplicationModule contains the package with the given name.
      Since:
      1.0.2
    • isOpen

      boolean isOpen()
      Returns whether the module is considered open.
      Since:
      1.2
      See Also:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object