Record Class RelationshipDecoration

java.lang.Object
java.lang.Record
com.kazforge.jsonapi.mapping.RelationshipDecoration

public record RelationshipDecoration(@Nullable com.kazforge.jsonapi.core.model.Links links) extends Record
Additive relationship-level decoration for domain writes.

Carries only Relationship.links for an already-mapped @JsonApiRelationship. It does not replace linkage, meta, or additional members, and it never creates a relationship that normal mapping did not produce.

  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    Returns an empty relationship decoration (no links).
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns true when this decoration carries no links.
    @Nullable com.kazforge.jsonapi.core.model.Links
    Returns the value of the links record component.
    links(com.kazforge.jsonapi.core.model.Links links)
    Alias for of(Links) that reads fluently when decorating relationships.
    of(com.kazforge.jsonapi.core.model.Links links)
    Creates a decoration with the given links.
    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

    • RelationshipDecoration

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

    • of

      public static RelationshipDecoration of(com.kazforge.jsonapi.core.model.Links links)
      Creates a decoration with the given links. links must not be null; use empty() when no linkage-agnostic decoration is needed.
    • links

      public static RelationshipDecoration links(com.kazforge.jsonapi.core.model.Links links)
      Alias for of(Links) that reads fluently when decorating relationships.
    • empty

      public static RelationshipDecoration empty()
      Returns an empty relationship decoration (no links).
    • isEmpty

      public boolean isEmpty()
      Returns true when this decoration carries no links. A present-empty Links (Links.empty() / "links":{}) is a wire-visible value and is not empty.
    • 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