java.lang.Object
All Implemented Interfaces:
HasDescription, CanOverrideDescription<Slice>, java.lang.Iterable<JavaClass>, java.util.Collection<JavaClass>, java.util.Set<JavaClass>

public final class Slice
extends ForwardingSet<JavaClass>
implements HasDescription, CanOverrideDescription<Slice>
A collection of JavaClasses modelling some domain aspect of a code basis. This is conceptually a cut through a code base according to business logic. Take for example

 com.mycompany.myapp.order
 com.mycompany.myapp.customer
 com.mycompany.myapp.user
 com.mycompany.myapp.authorization
 
The top level packages under 'myapp' could be considered slices according to different domain aspects.
Thus there could be a slice 'Order' housing all the classes from the order package, a slice 'Customer' housing all the classes from the customer package and so on.
  • Method Summary

    Modifier and Type Method Description
    Slice as​(java.lang.String pattern)
    The pattern can be a description with references to the matching groups by '$' and position.
    protected java.util.Set<JavaClass> delegate()  
    boolean equals​(java.lang.Object obj)  
    java.util.Set<Dependency> getDependenciesFromSelf()  
    java.util.Set<Dependency> getDependenciesToSelf()  
    java.lang.String getDescription()  
    java.lang.String getNamePart​(int index)
    Returns a matching part of this slice.
    int hashCode()  
    java.lang.String toString()  

    Methods inherited from class com.tngtech.archunit.base.ForwardingCollection

    add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.Collection

    parallelStream, removeIf, stream, toArray

    Methods inherited from interface java.lang.Iterable

    forEach

    Methods inherited from interface java.util.Set

    add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArray
  • Method Details

    • delegate

      protected java.util.Set<JavaClass> delegate()
      Specified by:
      delegate in class ForwardingSet<JavaClass>
    • getDescription

      @PublicAPI(usage=ACCESS) public java.lang.String getDescription()
      Specified by:
      getDescription in interface HasDescription
    • as

      @PublicAPI(usage=ACCESS) public Slice as​(java.lang.String pattern)
      The pattern can be a description with references to the matching groups by '$' and position. E.g. slices are created by 'some.svc.(*).sub.(*)', and the pattern is "the module $2 of service $1", and we match 'some.svc.foo.module.bar', then the resulting description will be "the module bar of service foo".
      Specified by:
      as in interface CanOverrideDescription<Slice>
      Parameters:
      pattern - The description pattern with numbered references of the form $i
      Returns:
      Same slice with different description
    • getDependenciesFromSelf

      @PublicAPI(usage=ACCESS) public java.util.Set<Dependency> getDependenciesFromSelf()
      Returns:
      All dependencies that originate from a class within this Slice and target a class outside of this Slice
    • getDependenciesToSelf

      @PublicAPI(usage=ACCESS) public java.util.Set<Dependency> getDependenciesToSelf()
      Returns:
      All dependencies that originate from outside of this Slice and target a class within this Slice
    • getNamePart

      @PublicAPI(usage=ACCESS) public java.lang.String getNamePart​(int index)
      Returns a matching part of this slice. E.g. if the slice was created by matching '..(*).controller.(*)..', against 'some.other.controller.here.more', then name part '1' would be 'other' and name part '2' would be 'here'.
      Parameters:
      index - The index of the matched group
      Returns:
      The part of the matched package name.
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface java.util.Collection<JavaClass>
      Specified by:
      hashCode in interface java.util.Set<JavaClass>
      Overrides:
      hashCode in class ForwardingCollection<JavaClass>
    • equals

      public boolean equals​(java.lang.Object obj)
      Specified by:
      equals in interface java.util.Collection<JavaClass>
      Specified by:
      equals in interface java.util.Set<JavaClass>
      Overrides:
      equals in class ForwardingCollection<JavaClass>
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class ForwardingCollection<JavaClass>