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, Collection<String> packages, com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> ignored, boolean useFullyQualifiedModuleNames, com.tngtech.archunit.core.importer.ImportOption option) -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(com.tngtech.archunit.core.domain.JavaClass type) Returns whether the givenJavaClass
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) Deprecated, for removal: This API element is subject to removal in a future version.Returns allApplicationModule
s registered as shared ones.Returns the source of theApplicationModules
.Returns the system name if defined.iterator()
static ApplicationModules
Creates a newApplicationModules
relative to the given modulith type.static ApplicationModules
of
(Class<?> modulithType, com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> ignored) Creates a newApplicationModules
relative to the given modulith type, aApplicationModuleDetectionStrategy
and aDescribedPredicate
which types and packages to ignore.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.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, Collection<String> packages, com.tngtech.archunit.base.DescribedPredicate<com.tngtech.archunit.core.domain.JavaClass> ignored, boolean useFullyQualifiedModuleNames, com.tngtech.archunit.core.importer.ImportOption option)
-
-
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<com.tngtech.archunit.core.domain.JavaClass> ignored) Creates a newApplicationModules
relative to the given modulith type, aApplicationModuleDetectionStrategy
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
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.
-
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.- Returns:
-
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
-
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.
-
iterator
- Specified by:
iterator
in interfaceIterable<ApplicationModule>
-
toString
-
getSource()
instead