Class NamedInterface

java.lang.Object
org.springframework.modulith.core.NamedInterface
All Implemented Interfaces:
Iterable<com.tngtech.archunit.core.domain.JavaClass>

public class NamedInterface extends Object implements Iterable<com.tngtech.archunit.core.domain.JavaClass>
A named interface into an ApplicationModule. This can either be a package, explicitly annotated with NamedInterface or a set of types annotated with the same annotation. Other ApplicationModules can define allowed dependencies to particular named interfaces via the $moduleName::$namedInterfaceName syntax.
Author:
Oliver Drotbohm
See Also:
  • Field Details

  • Method Details

    • of

      static List<NamedInterface> of(JavaPackage javaPackage)
      Returns all NamedInterfaces for the given JavaPackage.
      Parameters:
      javaPackage - must not be null.
      Returns:
      will never be null.
    • of

      static NamedInterface of(String name, Classes classes)
      Returns a NamedInterface with the given name, Classes and base JavaPackage.
      Parameters:
      name - must not be null or empty.
      classes - must not be null.
      Returns:
      will never be null.
    • unnamed

      static NamedInterface unnamed(JavaPackage javaPackage, boolean flatten)
      Creates an unnamed NamedInterface for the given JavaPackage.
      Parameters:
      javaPackage - must not be null.
      Returns:
      will never be null.
    • getName

      public String getName()
      Returns the NamedInterface's name.
      Returns:
      will never be null or empty.
    • getQualifiedName

      String getQualifiedName(ApplicationModuleIdentifier qualifier)
    • isUnnamed

      public boolean isUnnamed()
      Returns whether this is the unnamed (implicit) NamedInterface.
    • isNamed

      public boolean isNamed()
      Return whether this NamedInterface has an explicit name.
    • contains

      public boolean contains(com.tngtech.archunit.core.domain.JavaClass type)
      Returns whether the NamedInterface contains the given JavaClass.
      Parameters:
      type - must not be null.
    • contains

      public boolean contains(Class<?> type)
      Returns whether the NamedInterface contains the given type.
      Parameters:
      type - must not be null.
    • asJavaClasses

      public Stream<com.tngtech.archunit.core.domain.JavaClass> asJavaClasses()
      Returns a Stream of all JavaClasses contained in this interface.
      Returns:
      will never be null.
    • hasSameNameAs

      boolean hasSameNameAs(NamedInterface other)
      Returns whether the given NamedInterface has the same name as the current one.
      Parameters:
      other - must not be null.
    • iterator

      public Iterator<com.tngtech.archunit.core.domain.JavaClass> iterator()
      Specified by:
      iterator in interface Iterable<com.tngtech.archunit.core.domain.JavaClass>
    • merge

      Merges the current NamedInterface with the given NamedInterface.
      Parameters:
      other - must not be null.
      Returns:
      will never be null.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDefaultedNames

      static List<String> getDefaultedNames(NamedInterface annotation, String packageName)
      Returns the names declared in the given NamedInterface annotation or defaults to the local name of the given package if none declared.
      Parameters:
      annotation - must not be null.
      packageName - must not be null.
      Returns:
      will never be null.