Record Class RepresentationPolicy

java.lang.Object
java.lang.Record
com.kazforge.jsonapi.representation.RepresentationPolicy

public record RepresentationPolicy(IncludePolicy includePolicy, FieldPolicy fieldPolicy, int maxIncludeDepth, int maxIncludedResources) extends Record
Immutable application/runtime policy applied to a per-operation RepresentationSelection.

Defaults deny include traversal, allow every selected sparse field, limit include depth to 10, and limit included resources to 100.

A selection is a request and cannot override this policy. This policy governs representation shaping only; it is not complete authorization, persistence, endpoint-security, or query policy.

  • Constructor Details

    • RepresentationPolicy

      public RepresentationPolicy(IncludePolicy includePolicy, FieldPolicy fieldPolicy, int maxIncludeDepth, int maxIncludedResources)
      Creates an instance of a RepresentationPolicy record class.
      Parameters:
      includePolicy - the value for the includePolicy record component
      fieldPolicy - the value for the fieldPolicy record component
      maxIncludeDepth - the value for the maxIncludeDepth record component
      maxIncludedResources - the value for the maxIncludedResources record component
  • Method Details

    • defaults

      public static RepresentationPolicy defaults()
      Returns the default include and sparse-fieldset policy.
    • withIncludePolicy

      public RepresentationPolicy withIncludePolicy(IncludePolicy policy)
    • withFieldPolicy

      public RepresentationPolicy withFieldPolicy(FieldPolicy policy)
    • withMaxIncludeDepth

      public RepresentationPolicy withMaxIncludeDepth(int depth)
    • withMaxIncludedResources

      public RepresentationPolicy withMaxIncludedResources(int count)
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • includePolicy

      public IncludePolicy includePolicy()
      Returns the value of the includePolicy record component.
      Returns:
      the value of the includePolicy record component
    • fieldPolicy

      public FieldPolicy fieldPolicy()
      Returns the value of the fieldPolicy record component.
      Returns:
      the value of the fieldPolicy record component
    • maxIncludeDepth

      public int maxIncludeDepth()
      Returns the value of the maxIncludeDepth record component.
      Returns:
      the value of the maxIncludeDepth record component
    • maxIncludedResources

      public int maxIncludedResources()
      Returns the value of the maxIncludedResources record component.
      Returns:
      the value of the maxIncludedResources record component