Class JavaPackages

java.lang.Object
org.springframework.modulith.core.JavaPackages
All Implemented Interfaces:
Iterable<JavaPackage>

class JavaPackages extends Object implements Iterable<JavaPackage>
A collection of JavaPackages.
Since:
1.3
Author:
Oliver Drotbohm
  • Field Details

  • Constructor Details

  • Method Details

    • onlySubPackagesOf

      public static JavaPackages onlySubPackagesOf(JavaPackage reference, Collection<JavaPackage> packages)
      Creates a new JavaPackages 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 a JavaPackages instance that only contains the primary packages contained in the current JavaPackages. 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, and com.foo.bar, only com.foo and com.bar will be retained.

      Returns:
      will never be null.
    • stream

      Stream<JavaPackage> stream()
      Returns a stream of JavaPackages.
      Returns:
      will never be null.
    • iterator

      public Iterator<JavaPackage> iterator()
      Specified by:
      iterator in interface Iterable<JavaPackage>