Record Class DocumentEnvelope

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

public record DocumentEnvelope(@Nullable com.kazforge.jsonapi.core.model.Links links, @Nullable com.kazforge.jsonapi.core.model.Meta meta, @Nullable com.kazforge.jsonapi.core.model.JsonApiObject jsonapi) extends Record
Optional top-level links, meta, and JSON:API object attached during domain mapping.

A null component means that member is absent and is omitted from the serialized document. A non-null empty value remains present: for example, Links.empty() and Meta.empty() produce empty links and meta objects rather than absence.

  • Constructor Summary

    Constructors
    Constructor
    Description
    DocumentEnvelope(@Nullable com.kazforge.jsonapi.core.model.Links links, @Nullable com.kazforge.jsonapi.core.model.Meta meta, @Nullable com.kazforge.jsonapi.core.model.JsonApiObject jsonapi)
    Creates an instance of a DocumentEnvelope record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an envelope with every member absent, not present-empty.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @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.
    ofJsonApi(@Nullable com.kazforge.jsonapi.core.model.JsonApiObject jsonapi)
    Returns an envelope containing only a jsonapi object, or no members when null.
    ofLinks(@Nullable com.kazforge.jsonapi.core.model.Links links)
    Returns an envelope containing only links, or no members when null.
    ofMeta(@Nullable com.kazforge.jsonapi.core.model.Meta meta)
    Returns an envelope containing only metadata, or no members when null.
    final String
    Returns a string representation of this record class.
    withJsonApi(@Nullable com.kazforge.jsonapi.core.model.JsonApiObject jsonapi)
    Returns a copy replacing the jsonapi object, or omitting it when null.
    withLinks(@Nullable com.kazforge.jsonapi.core.model.Links links)
    Returns a copy replacing links, or omitting them when null.
    withMeta(@Nullable com.kazforge.jsonapi.core.model.Meta meta)
    Returns a copy replacing metadata, or omitting it when null.

    Methods inherited from class java.lang.Object

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

    • DocumentEnvelope

      public DocumentEnvelope(@Nullable com.kazforge.jsonapi.core.model.Links links, @Nullable com.kazforge.jsonapi.core.model.Meta meta, @Nullable com.kazforge.jsonapi.core.model.JsonApiObject jsonapi)
      Creates an instance of a DocumentEnvelope record class.
      Parameters:
      links - the value for the links record component
      meta - the value for the meta record component
      jsonapi - the value for the jsonapi record component
  • Method Details

    • empty

      public static DocumentEnvelope empty()
      Returns an envelope with every member absent, not present-empty.
    • ofLinks

      public static DocumentEnvelope ofLinks(@Nullable com.kazforge.jsonapi.core.model.Links links)
      Returns an envelope containing only links, or no members when null.
    • ofMeta

      public static DocumentEnvelope ofMeta(@Nullable com.kazforge.jsonapi.core.model.Meta meta)
      Returns an envelope containing only metadata, or no members when null.
    • ofJsonApi

      public static DocumentEnvelope ofJsonApi(@Nullable com.kazforge.jsonapi.core.model.JsonApiObject jsonapi)
      Returns an envelope containing only a jsonapi object, or no members when null.
    • withLinks

      public DocumentEnvelope withLinks(@Nullable com.kazforge.jsonapi.core.model.Links links)
      Returns a copy replacing links, or omitting them when null.
    • withMeta

      public DocumentEnvelope withMeta(@Nullable com.kazforge.jsonapi.core.model.Meta meta)
      Returns a copy replacing metadata, or omitting it when null.
    • withJsonApi

      public DocumentEnvelope withJsonApi(@Nullable com.kazforge.jsonapi.core.model.JsonApiObject jsonapi)
      Returns a copy replacing the jsonapi object, or omitting it when null.
    • 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.
    • 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
    • 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
    • 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