Record Class DocumentReadContext

java.lang.Object
java.lang.Record
com.kazforge.jsonapi.document.DocumentReadContext

public record DocumentReadContext(com.kazforge.jsonapi.core.aggregate.ValidationContext validationContext, PrimaryDataKind primaryDataKind) extends Record
Immutable document-read contract with independent validation and decoding axes.

validationContext() controls aggregate validation, including document usage, primary-data endpoint role, extension/profile policy, and endpoint identity. primaryDataKind() independently controls whether primary-data objects and arrays decode as resources or resource identifiers. Changing either component does not infer or rewrite the other.

In particular, identifierDefaults() selects identifier decoding with ValidationContext.defaults(); it does not select relationship-endpoint validation. Callers reading relationship linkage must also supply a validation context whose primary-data context is PrimaryDataContext.RELATIONSHIP.

  • Constructor Details

    • DocumentReadContext

      public DocumentReadContext(com.kazforge.jsonapi.core.aggregate.ValidationContext validationContext, PrimaryDataKind primaryDataKind)
      Creates an instance of a DocumentReadContext record class.
      Parameters:
      validationContext - the value for the validationContext record component
      primaryDataKind - the value for the primaryDataKind record component
  • Method Details

    • resourceDefaults

      public static DocumentReadContext resourceDefaults()
      Resource decoding with ValidationContext.defaults().
    • identifierDefaults

      public static DocumentReadContext identifierDefaults()
      Identifier decoding with ValidationContext.defaults(); the endpoint role stays resource.
    • of

      public static DocumentReadContext of(com.kazforge.jsonapi.core.aggregate.ValidationContext validationContext, PrimaryDataKind primaryDataKind)
    • withValidationContext

      public DocumentReadContext withValidationContext(com.kazforge.jsonapi.core.aggregate.ValidationContext validationContext)
      Returns a copy with the given validation policy and the same primary-data decoding kind.
    • withPrimaryDataKind

      public DocumentReadContext withPrimaryDataKind(PrimaryDataKind primaryDataKind)
      Returns a copy with the given primary-data decoding kind and the same validation policy.
    • 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.
    • validationContext

      public com.kazforge.jsonapi.core.aggregate.ValidationContext validationContext()
      Returns the value of the validationContext record component.
      Returns:
      the value of the validationContext record component
    • primaryDataKind

      public PrimaryDataKind primaryDataKind()
      Returns the value of the primaryDataKind record component.
      Returns:
      the value of the primaryDataKind record component