Record Class PresetRule

java.lang.Object
java.lang.Record
dev.archunitjava.presets.PresetRule
All Implemented Interfaces:
Comparable<PresetRule>

public record PresetRule(String key, PresetRuleMode mode, List<String> subjects, List<String> relatedLayers, Optional<String> displayName, Optional<String> rationale) extends Record implements Comparable<PresetRule>
Inspectable recipe that expands to one ordinary ArchitectureRule.
  • Constructor Details

    • PresetRule

      public PresetRule(String key, PresetRuleMode mode, List<String> subjects, List<String> relatedLayers, Optional<String> displayName, Optional<String> rationale)
      Creates an instance of a PresetRule record class.
      Parameters:
      key - the value for the key record component
      mode - the value for the mode record component
      subjects - the value for the subjects record component
      relatedLayers - the value for the relatedLayers record component
      displayName - the value for the displayName record component
      rationale - the value for the rationale record component
  • Method Details

    • exactlyOneLayer

      public static PresetRule exactlyOneLayer(String key)
    • mayOnlyAccess

      public static PresetRule mayOnlyAccess(String key, String subject, Collection<String> allowedLayers)
    • noAccess

      public static PresetRule noAccess(String key, String subject, Collection<String> forbiddenLayers)
    • onlyAccessedBy

      public static PresetRule onlyAccessedBy(String key, String subject, Collection<String> allowedLayers)
    • isolated

      public static PresetRule isolated(String key, String subject)
    • publicInterface

      public static PresetRule publicInterface(String key, Collection<String> consumerLayers, Collection<String> approvedInterfaceLayers)
    • as

      public PresetRule as(String value)
    • because

      public PresetRule because(String value)
    • compareTo

      public int compareTo(PresetRule other)
      Specified by:
      compareTo in interface Comparable<PresetRule>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • key

      public String key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • mode

      public PresetRuleMode mode()
      Returns the value of the mode record component.
      Returns:
      the value of the mode record component
    • subjects

      public List<String> subjects()
      Returns the value of the subjects record component.
      Returns:
      the value of the subjects record component
    • relatedLayers

      public List<String> relatedLayers()
      Returns the value of the relatedLayers record component.
      Returns:
      the value of the relatedLayers record component
    • displayName

      public Optional<String> displayName()
      Returns the value of the displayName record component.
      Returns:
      the value of the displayName record component
    • rationale

      public Optional<String> rationale()
      Returns the value of the rationale record component.
      Returns:
      the value of the rationale record component