Class JavaPackages
java.lang.Object
org.springframework.modulith.core.JavaPackages
- All Implemented Interfaces:
Iterable<JavaPackage>
A collection of
JavaPackage
s.- Since:
- 1.3
- Author:
- Oliver Drotbohm
-
Field Summary
-
Constructor Summary
ConstructorDescriptionJavaPackages
(Collection<JavaPackage> packages) Creates a newJavaPackages
instance for the givenJavaPackage
s. -
Method Summary
Modifier and TypeMethodDescription(package private) JavaPackages
flatten()
Returns aJavaPackages
instance that only contains the primary packages contained in the currentJavaPackages
.iterator()
static JavaPackages
onlySubPackagesOf
(JavaPackage reference, Collection<JavaPackage> packages) Creates a newJavaPackages
containing all sub-packages of the given reference package contained in the given packages.(package private) Stream<JavaPackage>
stream()
Returns a stream ofJavaPackage
s.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
NONE
-
-
Constructor Details
-
JavaPackages
JavaPackages(Collection<JavaPackage> packages) Creates a newJavaPackages
instance for the givenJavaPackage
s.- Parameters:
packages
- must not be null.
-
-
Method Details
-
onlySubPackagesOf
public static JavaPackages onlySubPackagesOf(JavaPackage reference, Collection<JavaPackage> packages) Creates a newJavaPackages
containing all sub-packages of the given reference package contained in the given packages.- Parameters:
reference
- must not be null.packages
- must not be null.- Returns:
- will never be null.
-
flatten
JavaPackages flatten()Returns aJavaPackages
instance that only contains the primary packages contained in the currentJavaPackages
. Any package that's a sub-package of any other package will get dropped.In other words for a list of {code com.foo},
com.bar
, andcom.foo.bar
, onlycom.foo
andcom.bar
will be retained.- Returns:
- will never be null.
-
stream
Stream<JavaPackage> stream()Returns a stream ofJavaPackage
s.- Returns:
- will never be null.
-
iterator
- Specified by:
iterator
in interfaceIterable<JavaPackage>
-