Class ApplicationModules
java.lang.Object
org.springframework.modulith.core.ApplicationModules
- All Implemented Interfaces:
Iterable<ApplicationModule>
- Author:
- Oliver Drotbohm, Peter Gafert
-
Nested Class Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
ApplicationModules
(ModulithMetadata metadata, com.tngtech.archunit.base.DescribedPredicate<? super com.tngtech.archunit.core.domain.JavaClass> ignored, com.tngtech.archunit.core.importer.ImportOption option) Creates a newApplicationModules
instance.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) Deprecated, for removal: This API element is subject to removal in a future version.since 1.2, for removal in 1.3. -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(com.tngtech.archunit.core.domain.JavaClass type) Returns whether the givenJavaClass
is contained within theApplicationModules
.boolean
Returns whether the givenClass
is contained within theApplicationModules
.Executes all verifications to be applied and returnsViolations
if any occured.Returns aComparator
that will sort objects based on their types' application module.getModuleByName
(String name) Returns theApplicationModule
with the given name.getModuleByType
(com.tngtech.archunit.core.domain.JavaClass type) Returns the module that contains the givenJavaClass
.getModuleByType
(Class<?> candidate) Returns theApplicationModule
containing the given type.getModuleByType
(String candidate) Returns theApplicationModule
containing the type with the given simple or fully-qualified name.getModuleForPackage
(String name) Returns theApplicationModule
containing the given package.Deprecated, for removal: This API element is subject to removal in a future version.usegetSource()
insteadgetParentOf
(ApplicationModule module) Returns the parentApplicationModule
if the given one has one.Returns allApplicationModule
s registered as shared ones.Returns the source of theApplicationModules
.Returns the system name if defined.boolean
hasParent
(ApplicationModule module) Returns whether the givenApplicationModule
has a parent one.iterator()
static ApplicationModules
Creates a newApplicationModules
relative to the given modulith type.static ApplicationModules
of
(Class<?> modulithType, com.tngtech.archunit.base.DescribedPredicate<? super com.tngtech.archunit.core.domain.JavaClass> ignored) Creates a newApplicationModules
relative to the given modulith type, and aDescribedPredicate
which types and packages to ignore.static ApplicationModules
Creates a newApplicationModules
instance for the given type andImportOption
.static ApplicationModules
Creates a newApplicationModules
instance for the given package name.static ApplicationModules
of
(String javaPackage, com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> ignored) Creates a newApplicationModules
instance for the given package name and ignored classes.static ApplicationModules
Creates a newApplicationModules
instance for the given package andImportOption
.stream()
Returns allApplicationModule
s.toString()
verify()
Execute all verifications to be applied, unless the verification has been executed before.boolean
withinRootPackages
(String className) Returns whether the given type is contained in one of the root packages (not including sub-packages) of the modules.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ApplicationModules
protected ApplicationModules(ModulithMetadata metadata, com.tngtech.archunit.base.DescribedPredicate<? super com.tngtech.archunit.core.domain.JavaClass> ignored, com.tngtech.archunit.core.importer.ImportOption option) Creates a newApplicationModules
instance.- Parameters:
metadata
- must not be null.ignored
- must not be null.option
- must not be null.
-
ApplicationModules
@Deprecated(forRemoval=true) 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) Deprecated, for removal: This API element is subject to removal in a future version.since 1.2, for removal in 1.3. UseApplicationModules(org.springframework.modulith.core.ModulithMetadata,com.tngtech.archunit.base.DescribedPredicate<? super com.tngtech.archunit.core.domain.JavaClass>,com.tngtech.archunit.core.importer.ImportOption)
instead and set upModulithMetadata
to contain the packages you want to use.Creates a newApplicationModules
instance.- Parameters:
metadata
- must not be null.packages
- must not be null.ignored
- must not be null.useFullyQualifiedModuleNames
- can be null.option
- must not be null.
-
-
Method Details
-
of
Creates a newApplicationModules
relative to the given modulith type. Will inspect theModulith
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 newApplicationModules
relative to the given modulith type, and aDescribedPredicate
which types and packages to ignore. Will inspect theModulith
andModulithic
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(Class<?> modulithType, com.tngtech.archunit.core.importer.ImportOption options) Creates a newApplicationModules
instance for the given type andImportOption
.- Parameters:
modulithType
- must not be null.options
- must not be null.- Returns:
- will never be null.
- Since:
- 1.2
-
of
Creates a newApplicationModules
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<com.tngtech.archunit.core.domain.JavaClass> ignored) Creates a newApplicationModules
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.
-
of
public static ApplicationModules of(String javaPackage, com.tngtech.archunit.core.importer.ImportOption options) Creates a newApplicationModules
instance for the given package andImportOption
.- Parameters:
javaPackage
- must not be null.options
- must not be null.- Returns:
- will never be null.
- Since:
- 1.2
-
getModulithSource
Deprecated, for removal: This API element is subject to removal in a future version.usegetSource()
insteadReturns the source of theApplicationModules
. Either a main application class or a package name.- Returns:
- will never be null.
-
getSource
Returns the source of theApplicationModules
. Either a main application class or a package name.- Returns:
- will never be null.
-
contains
public boolean contains(com.tngtech.archunit.core.domain.JavaClass type) Returns whether the givenJavaClass
is contained within theApplicationModules
.- Parameters:
type
- must not be null.
-
contains
Returns whether the givenClass
is contained within theApplicationModules
.- Parameters:
type
- must not be null.
-
withinRootPackages
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
Returns theApplicationModule
with the given name.- Parameters:
name
- must not be null or empty.- Returns:
-
getModuleByType
Returns the module that contains the givenJavaClass
.- Parameters:
type
- must not be null.- Returns:
-
getModuleByType
Returns theApplicationModule
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
Returns theApplicationModule
containing the given type.- Parameters:
candidate
- must not be null.- Returns:
- will never be null.
-
getModuleForPackage
Returns theApplicationModule
containing the given package.- Parameters:
name
- must not be null or empty.- Returns:
- will never be null.
-
verify
Execute all verifications to be applied, unless the verification has been executed before.- Returns:
- will never be null.
-
detectViolations
Executes all verifications to be applied and returnsViolations
if any occured. Will always execute the verifications in contrast toverify()
which just runs once.- Returns:
- will never be null.
- See Also:
-
stream
Returns allApplicationModule
s.- Returns:
- will never be null.
-
getSystemName
Returns the system name if defined.- Returns:
-
getComparator
Returns aComparator
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 (viaOrder
orOrdered
) will be applied.- Returns:
- will never be null.
-
getParentOf
Returns the parentApplicationModule
if the given one has one.- Parameters:
module
- must not be null.- Returns:
- will never be null.
- Since:
- 1.3
-
hasParent
Returns whether the givenApplicationModule
has a parent one.- Parameters:
module
- must not be null.- Since:
- 1.3
-
iterator
- Specified by:
iterator
in interfaceIterable<ApplicationModule>
-
toString
-