Class NamedInterfaces.Builder

java.lang.Object
org.springframework.modulith.core.NamedInterfaces.Builder
Enclosing class:
NamedInterfaces

public static class NamedInterfaces.Builder extends Object
A builder API to manually construct NamedInterfaces instances. Allows selecting packages to create NamedInterface instances for based on excluding and including predicates, name matches etc. Will always include the unnamed named interface as it's required for a valid application module.
Since:
1.4
Author:
Oliver Drotbohm
  • Method Details

    • recursive

      public NamedInterfaces.Builder recursive()
      Configures the builder to not only consider directly nested packages but also ones nested in those.
      Returns:
      will never be null.
    • matching

      public NamedInterfaces.Builder matching(String... names)
      Adds all packages with the trailing name relative to the base package matching the given names or expressions, unless set up to be excluded (see excluding(Predicate) and overloads).. For a base package com.acme, the trailing name of package com.acme.foo would be foo. For com.acme.foo.bar it would be foo.bar.

      Expressions can use wildcards, such as * (for multi-character matches) and ? (for single-character ones). As soon as an expression contains a dot (.), the expression is applied to the entire trailing name. Expressions with a dot are applied to all name segments individually. In other words, an expression foo would match both the trailing names foo, foo.bar, and bar.foo.

      Parameters:
      names - must not be null.
      Returns:
      will never be null.
      See Also:
    • matching

      public NamedInterfaces.Builder matching(Collection<String> names)
      Adds all packages with the trailing name relative to the base package matching the given names or expressions, unless set up to be excluded (see excluding(Predicate) and overloads). For a base package com.acme, the trailing name of package com.acme.foo would be foo. For com.acme.foo.bar it would be foo.bar.

      Expressions can use wildcards, such as * (for multi-character matches) and ? (for single-character ones). As soon as an expression contains a dot (.), the expression is applied to the entire trailing name. Expressions with a dot are applied to all name segments individually. In other words, an expression foo would match both the trailing names foo, foo.bar, and bar.foo.

      Parameters:
      names - must not be null.
      Returns:
      will never be null.
      See Also:
    • including

      public NamedInterfaces.Builder including(Predicate<JavaPackage> inclusions)
      Adds all packages matching the given predicate as named interface.
      Parameters:
      inclusions - must not be null.
      Returns:
      will never be null.
      See Also:
    • excluding

      public NamedInterfaces.Builder excluding(String... expressions)
      Excludes the packages with the given name expressions from being considered as named interface. See matching(String...) for details on matching expressions.
      Parameters:
      expressions - must not be null.
      Returns:
      will never be null.
      See Also:
    • excluding

      public NamedInterfaces.Builder excluding(Collection<String> expressions)
      Excludes the packages with the given name expressions from being considered as named interface. See matching(Collection) for details on matching expressions.
      Parameters:
      expressions - must not be null.
      Returns:
      will never be null.
      See Also:
    • excluding

      public NamedInterfaces.Builder excluding(Predicate<JavaPackage> exclusions)
      Excludes the packages matching the given Predicate from being considered as named interface.
      Parameters:
      exclusions - must not be null.
      Returns:
      will never be null.
      See Also:
    • build

      public NamedInterfaces build()
      Creates a NamedInterfaces instance according to the builder setup. Will always include the unnamed interface established by the JavaPackage the NamedInterfaces.Builder was set up for originally, as it's a required abstraction for every application module.
      Returns:
      will never be null.