Record Class LayerDependencies

java.lang.Object
java.lang.Record
com.pragma.archetype.domain.model.structure.LayerDependencies

public record LayerDependencies(Map<String,List<String>> allowedDependencies) extends Record
Defines allowed dependencies between architectural layers. Used to validate that generated code respects dependency rules.
  • Constructor Details

    • LayerDependencies

      public LayerDependencies(Map<String,List<String>> allowedDependencies)
      Creates an instance of a LayerDependencies record class.
      Parameters:
      allowedDependencies - the value for the allowedDependencies record component
  • Method Details

    • canDependOn

      public boolean canDependOn(String fromLayer, String toLayer)
      Checks if a layer can depend on another layer.
      Parameters:
      fromLayer - The layer that wants to depend
      toLayer - The layer to depend on
      Returns:
      true if the dependency is allowed
    • getAllowedDependenciesFor

      public List<String> getAllowedDependenciesFor(String layer)
      Gets all layers that a given layer can depend on.
      Parameters:
      layer - The layer to check
      Returns:
      List of allowed dependencies, or empty list if none
    • validateDependency

      public ValidationResult validateDependency(String fromLayer, String toLayer)
      Validates a dependency relationship.
      Parameters:
      fromLayer - The layer that wants to depend
      toLayer - The layer to depend on
      Returns:
      ValidationResult indicating if dependency is valid
    • 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.
    • allowedDependencies

      public Map<String,List<String>> allowedDependencies()
      Returns the value of the allowedDependencies record component.
      Returns:
      the value of the allowedDependencies record component