Class ApplicationModule
java.lang.Object
org.springframework.modulith.core.ApplicationModule
- All Implemented Interfaces:
Comparable<ApplicationModule>
An application module.
- Author:
- Oliver Drotbohm
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA collection wrapper forApplicationModule.AllowedDependencyinstances.static classDescribes a dependency explicitly declared as allowed for anApplicationModule.(package private) static class -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newApplicationModulefrom the givenApplicationModuleSource.ApplicationModule(ApplicationModuleSource source, JavaPackages exclusions) Creates a newApplicationModulefor the given base package and whether to use fully-qualified module names. -
Method Summary
Modifier and TypeMethodDescriptionintbooleancontains(com.tngtech.archunit.core.domain.JavaClass type) Returns whether the current module contains the given type.booleanReturns whether the current module contains the given type.booleanReturns whether the given module contains a type with the given simple or fully qualified name.(package private) booleancontainsPackage(String packageName) Returns whether theApplicationModulecontains 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) booleancontainsTypeInAnyParent(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) booleanList<com.tngtech.archunit.core.domain.JavaClass>Returns all types that are considered aggregate roots.getAllDependencies(ApplicationModules modules, DependencyType... type) Returns the allApplicationModuleDependencies(including transitive ones) of the currentApplicationModule.getAllowedDependencies(ApplicationModules modules) Returns all declared allowed module dependencies, either explicitly declared or defined as shared on the givenApplicationModulesinstance.getArchitecturallyEvidentType(Class<?> type) Returns theArchitecturallyEvidentTypefor the given type.Returns the module's base package.getBootstrapBasePackages(ApplicationModules modules, DependencyDepth depth) Returns allJavaPackagefor 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) ClassesgetDependencies(ApplicationModules modules, DependencyDepth depth, DependencyType... types) getDependencies(ApplicationModules modules, DependencyType... type) Deprecated.since 1.3.getDirectDependencies(ApplicationModules modules, DependencyType... type) Returns the directApplicationModuleDependenciesof the currentApplicationModule.(package private) Collection<ApplicationModule>Returns theApplicationModules directly nested inside the current one.Returns the name of theApplicationModulefor display purposes.List<com.tngtech.archunit.core.domain.JavaClass>getEventsListenedTo(ApplicationModules modules) Returns all event types the current module exposes an event listener for.Returns the logical identifier of the module.Collection<com.tngtech.archunit.core.domain.JavaClass>Returns all types internal to the module.getName()Deprecated.since 1.3, usegetIdentifier()instead.Returns allNamedInterfacesexposed by the module.(package private) Collection<ApplicationModule>getNestedModules(ApplicationModules modules) Returns all of the currentApplicationModule's nestedApplicationModules 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 allEventTypes published by the module.Returns allSpringBeans contained in the module.getSpringBeans(Class<?> type) Returns allSpringBeans assignable to the given type.(package private) ClassesOptional<com.tngtech.archunit.core.domain.JavaClass>Returns theJavaClassfor the given candidate simple or fully-qualified type name.List<com.tngtech.archunit.core.domain.JavaClass>Returns all value types contained in the module.(package private) booleanhasBasePackage(String candidate) Returns whether the module has a base package with the given name.inthashCode()booleanisExposed(com.tngtech.archunit.core.domain.JavaClass type) Returns whether the givenJavaClassis exposed by the current module, i.e. whether it's part of any of the module's named interfaces.booleanReturns whether the givenJavaClassis exposed by the current module, i.e. whether it's part of any of the module's named interfaces.booleanisOpen()Returns whether the module is considered open.booleanReturns whether the module is considered a root one, i.e., it is an artificial one created for each base package configured.toString()toString(@Nullable ApplicationModules modules) voidverifyDependencies(ApplicationModules modules)
-
Constructor Details
-
ApplicationModule
ApplicationModule(ApplicationModuleSource source) Creates a newApplicationModulefrom the givenApplicationModuleSource.- Parameters:
source- must not be null.
-
ApplicationModule
ApplicationModule(ApplicationModuleSource source, JavaPackages exclusions) Creates a newApplicationModulefor 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 allNamedInterfacesexposed by the module.- Returns:
- the namedInterfaces will never be null.
-
getName
Deprecated.since 1.3, usegetIdentifier()instead.Returns the logical name of the module.- Returns:
- will never be null or empty.
-
getIdentifier
Returns the logical identifier of the module.- Returns:
- will never be null.
- Since:
- 1.3
-
getDisplayName
Returns the name of theApplicationModulefor display purposes.- Returns:
- will never be null or empty.
-
getDependencies
@Deprecated public ApplicationModuleDependencies getDependencies(ApplicationModules modules, DependencyType... type) Deprecated.since 1.3. UsegetDirectDependencies(ApplicationModules, DependencyType...)instead.ReturnsApplicationModule.AllowedDependenciesof the currentApplicationModule.- Parameters:
modules- must not be null.type- must not be null.- Returns:
- will never be null.
-
getDirectDependencies
public ApplicationModuleDependencies getDirectDependencies(ApplicationModules modules, DependencyType... type) Returns the directApplicationModuleDependenciesof the currentApplicationModule.- Parameters:
modules- must not be null.type- must not be null.- Returns:
- will never be null.
-
getAllDependencies
public ApplicationModuleDependencies getAllDependencies(ApplicationModules modules, DependencyType... type) Returns the allApplicationModuleDependencies(including transitive ones) 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 allEventTypes 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 allJavaPackagefor the current module including the ones by its dependencies.- Parameters:
modules- must not be null.depth- must not be null.- Returns:
-
getSpringBeans
Returns allSpringBeans contained in the module.- Returns:
- will never be null.
-
getSpringBeans
Returns allSpringBeans assignable to the given type.- Parameters:
type- must not be null.- Returns:
- will never be null.
- Since:
- 1.4
-
getArchitecturallyEvidentType
Returns theArchitecturallyEvidentTypefor 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- must not be null.
-
getType
Returns theJavaClassfor the given candidate simple or 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 givenJavaClassis 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.
-
isExposed
Returns whether the givenJavaClassis 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.- Since:
- 1.2.8, 1.3.2
-
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
-
contains
Returns whether the given module contains a type with the given simple or fully qualified name.- Parameters:
candidate- must not be null.- Since:
- 1.3
-
toString
-
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
-
getSpringBeansInternal
Classes getSpringBeansInternal() -
getAllowedDependencies
Returns all declared allowed module dependencies, either explicitly declared or defined as shared on the givenApplicationModulesinstance.- Parameters:
modules- must not be null.- Returns:
- will never be null.
- Since:
- 1.4.2, previously package private
-
containsPackage
Returns whether theApplicationModulecontains 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
ApplicationModulecontains the package with the given name. - Since:
- 1.0.2
-
isOpen
public boolean isOpen()Returns whether the module is considered open.- Since:
- 1.4.2, previously package private 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
-
getDependencies
public ApplicationModuleDependencies getDependencies(ApplicationModules modules, DependencyDepth depth, DependencyType... types) -
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareToin 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 theApplicationModules 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 nestedApplicationModules 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
-
getInternalTypes
Returns all types internal to the module.- Returns:
- will never be null.
- Since:
- 1.4
-