Record Class ResourceDocument<T>

java.lang.Object
java.lang.Record
com.kazforge.jsonapi.api.ResourceDocument<T>

public record ResourceDocument<T>(T resource, @Nullable com.kazforge.jsonapi.core.model.Meta meta, @Nullable com.kazforge.jsonapi.core.model.Links links, @Nullable com.kazforge.jsonapi.core.model.JsonApiObject jsonapi, @Nullable List<com.kazforge.jsonapi.core.model.ResourceObject> included) extends Record
Level-1 typed read result for one resource plus selected document-level state.

Carries the bound primary DTO together with top-level meta, links, jsonapi, and compound included state. Java null components mean the member was absent; a non-null empty included list preserves a present "included": [] member. Included resources are carried as validated core ResourceObject values in wire order, never bound to DTOs: included state may be heterogeneous while this path stays homogeneous and registry-free. Included resources are never hydrated into relationship properties. The result is returned only after complete document validation. Error documents, identifier primary data, and additional document members are not carried; reads requiring those states use the documents facet or an advanced envelope instead.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ResourceDocument(T resource, @Nullable com.kazforge.jsonapi.core.model.Meta meta, @Nullable com.kazforge.jsonapi.core.model.Links links, @Nullable com.kazforge.jsonapi.core.model.JsonApiObject jsonapi, @Nullable List<com.kazforge.jsonapi.core.model.ResourceObject> included)
    Creates an instance of a ResourceDocument record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @Nullable List<com.kazforge.jsonapi.core.model.ResourceObject>
    Returns the value of the included record component.
    @Nullable com.kazforge.jsonapi.core.model.JsonApiObject
    Returns the value of the jsonapi record component.
    @Nullable com.kazforge.jsonapi.core.model.Links
    Returns the value of the links record component.
    @Nullable com.kazforge.jsonapi.core.model.Meta
    Returns the value of the meta record component.
    Returns the value of the resource record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ResourceDocument

      public ResourceDocument(T resource, @Nullable com.kazforge.jsonapi.core.model.Meta meta, @Nullable com.kazforge.jsonapi.core.model.Links links, @Nullable com.kazforge.jsonapi.core.model.JsonApiObject jsonapi, @Nullable List<com.kazforge.jsonapi.core.model.ResourceObject> included)
      Creates an instance of a ResourceDocument record class.
      Parameters:
      resource - the value for the resource record component
      meta - the value for the meta record component
      links - the value for the links record component
      jsonapi - the value for the jsonapi record component
      included - the value for the included record component
  • Method Details

    • 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.
    • resource

      public T resource()
      Returns the value of the resource record component.
      Returns:
      the value of the resource record component
    • meta

      public @Nullable com.kazforge.jsonapi.core.model.Meta meta()
      Returns the value of the meta record component.
      Returns:
      the value of the meta record component
    • links

      public @Nullable com.kazforge.jsonapi.core.model.Links links()
      Returns the value of the links record component.
      Returns:
      the value of the links record component
    • jsonapi

      public @Nullable com.kazforge.jsonapi.core.model.JsonApiObject jsonapi()
      Returns the value of the jsonapi record component.
      Returns:
      the value of the jsonapi record component
    • included

      public @Nullable List<com.kazforge.jsonapi.core.model.ResourceObject> included()
      Returns the value of the included record component.
      Returns:
      the value of the included record component