Class ApplicationModule
java.lang.Object
org.springframework.modulith.core.ApplicationModule
- All Implemented Interfaces:
Comparable<ApplicationModule>
An application module.
- Author:
- Oliver Drotbohm
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
A collection wrapper forApplicationModule.DeclaredDependency
instances.(package private) static class
(package private) static class
-
Constructor Summary
ConstructorDescriptionCreates a newApplicationModule
from the givenApplicationModuleSource
.ApplicationModule
(ApplicationModuleSource source, JavaPackages exclusions) Creates a newApplicationModule
for the given base package and whether to use fully-qualified module names. -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
contains
(com.tngtech.archunit.core.domain.JavaClass type) Returns whether the current module contains the given type.boolean
Returns whether the current module contains the given type.(package private) boolean
Returns whether the given module contains a type with the given simple or fully qualified name.(package private) boolean
containsPackage
(String packageName) Returns whether theApplicationModule
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.(package private) boolean
containsTypeInAnyParent
(com.tngtech.archunit.core.domain.JavaClass type, ApplicationModules modules) Returns whether the given type is contained in any of the parent modules of the current one.detectDependencies
(ApplicationModules modules) boolean
List<com.tngtech.archunit.core.domain.JavaClass>
Returns all types that are considered aggregate roots.getArchitecturallyEvidentType
(Class<?> type) Returns theArchitecturallyEvidentType
for the given type.Returns the module's base package.getBootstrapBasePackages
(ApplicationModules modules, DependencyDepth depth) Returns allJavaPackage
for the current module including the ones by its dependencies.Returns all modules that contain types which the types of the current module depend on.getBootstrapDependencies
(ApplicationModules modules, DependencyDepth depth) (package private) Classes
(package private) ApplicationModule.DeclaredDependencies
Returns all declared module dependencies, either explicitly declared or defined as shared on the givenApplicationModules
instance.getDependencies
(ApplicationModules modules, DependencyType... type) ReturnsApplicationModule.DeclaredDependencies
of the currentApplicationModule
.(package private) Collection<ApplicationModule>
Returns theApplicationModule
s directly nested inside the current one.Returns the name of theApplicationModule
for display purposes.List<com.tngtech.archunit.core.domain.JavaClass>
getEventsListenedTo
(ApplicationModules modules) Returns all event types the current module exposes an event listener for.getName()
Returns the logical name of the module.Returns allNamedInterfaces
exposed by the module.(package private) Collection<ApplicationModule>
getNestedModules
(ApplicationModules modules) Returns all of the currentApplicationModule
's nestedApplicationModule
s including ones contained in nested modules in turn.(package private) Optional<ApplicationModule>
getParentModule
(ApplicationModules modules) Returns the current module's immediate parent module, if present.Returns allEventType
s published by the module.Returns allSpringBean
s contained in the module.(package private) Classes
Optional<com.tngtech.archunit.core.domain.JavaClass>
Returns theJavaClass
for the given candidate simple of fully-qualified type name.List<com.tngtech.archunit.core.domain.JavaClass>
Returns all value types contained in the module.(package private) boolean
hasBasePackage
(String candidate) Returns whether the module has a base package with the given name.int
hashCode()
boolean
isExposed
(com.tngtech.archunit.core.domain.JavaClass type) Returns whether the givenJavaClass
is exposed by the current module, i.e. whether it's part of any of the module's named interfaces.(package private) boolean
isOpen()
Returns whether the module is considered open.boolean
Returns whether the module is considered a root one, i.e., it is an artificial one created for each base package configured.toString()
toString
(ApplicationModules modules) void
verifyDependencies
(ApplicationModules modules)
-
Constructor Details
-
ApplicationModule
ApplicationModule(ApplicationModuleSource source) Creates a newApplicationModule
from the givenApplicationModuleSource
.- Parameters:
source
- must not be null.
-
ApplicationModule
ApplicationModule(ApplicationModuleSource source, JavaPackages exclusions) Creates a newApplicationModule
for the given base package and whether to use fully-qualified module names.- Parameters:
source
- must not be null.exclusions
- must not be null.
-
-
Method Details
-
getBasePackage
Returns the module's base package.- Returns:
- the basePackage
-
getNamedInterfaces
Returns allNamedInterfaces
exposed by the module.- Returns:
- the namedInterfaces will never be null.
-
getName
Returns the logical name of the module.- Returns:
- will never be null or empty.
-
getDisplayName
Returns the name of theApplicationModule
for display purposes.- Returns:
- will never be null or empty.
-
getDependencies
public ApplicationModuleDependencies getDependencies(ApplicationModules modules, DependencyType... type) ReturnsApplicationModule.DeclaredDependencies
of the currentApplicationModule
.- 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
Returns allEventType
s published by the module.- Returns:
- will never be null.
-
getValueTypes
Returns all value types contained in the module.- Returns:
- will never be null.
-
getAggregateRoots
Returns all types that are considered aggregate roots.- Returns:
- will never be null.
-
getBootstrapDependencies
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 allJavaPackage
for the current module including the ones by its dependencies.- Parameters:
modules
- must not be null.depth
- must not be null.- Returns:
-
getSpringBeans
Returns allSpringBean
s contained in the module.- Returns:
- will never be null.
-
getArchitecturallyEvidentType
Returns theArchitecturallyEvidentType
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) Returns whether the current module contains the given type.- Parameters:
type
- must not be null.
-
contains
Returns whether the current module contains the given type.- Parameters:
type
- can be null.
-
getType
Returns theJavaClass
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 givenJavaClass
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
-
detectDependencies
-
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
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
-
toString
-
getSpringBeansInternal
Classes getSpringBeansInternal() -
getDeclaredDependencies
Returns all declared module dependencies, either explicitly declared or defined as shared on the givenApplicationModules
instance.- Parameters:
modules
- must not be null.- Returns:
-
contains
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
Returns whether theApplicationModule
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:
-
containsTypeInAnyParent
boolean containsTypeInAnyParent(com.tngtech.archunit.core.domain.JavaClass type, ApplicationModules modules) Returns whether the given type is contained in any of the parent modules of the current one.- Parameters:
type
- must not be null.modules
- must not be null.- Since:
- 1.3
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<ApplicationModule>
-
getParentModule
Returns the current module's immediate parent module, if present.- Parameters:
modules
- must not be null.- Returns:
- will never be null.
- Since:
- 1.3
-
getDirectlyNestedModules
Returns theApplicationModule
s directly nested inside the current one.- Parameters:
modules
- must not be null.- Returns:
- will never be null.
- Since:
- 1.3
-
getNestedModules
Returns all of the currentApplicationModule
's nestedApplicationModule
s including ones contained in nested modules in turn.- Parameters:
modules
- must not be null.- Returns:
- will never be null.
- Since:
- 1.3
-
getClasses
Classes getClasses()- Returns:
- the classes
-