Class JavaPackages

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

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

  • Constructor Details

  • Method Details

    • 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

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

      JavaPackages getSubPackagesOf(JavaPackage pkg)
      Returns all JavaPackages that are a sub-package of the given one.
      Parameters:
      pkg - must not be null.
      Returns:
      will never be null.
      Since:
      1.4.2
    • contains

      public boolean contains(JavaPackage pkg)
    • contains

      boolean contains(Class<?> type)
      Returns whether any of the packages contains the given type.
      Parameters:
      type - must not be null.
      Since:
      1.4.6, 2.0.1
    • couldContain

      public boolean couldContain(Class<?> type)
      Returns whether any of the the packages could contain the type independent of the actual types backing the current instance.
      Parameters:
      type - must not be null.
      Since:
      1.4.6, 2.0.1
      See Also:
    • couldContain

      public boolean couldContain(String type)
      Returns whether any of the the packages could contain the type independent of the actual types backing the current instance.
      Parameters:
      type - must not be null.
      Since:
      1.4.6, 2.0.1
      See Also:
    • iterator

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

      public String toString()
      Overrides:
      toString in class Object