Class ResourceDecoration

java.lang.Object
com.kazforge.jsonapi.mapping.ResourceDecoration

public final class ResourceDecoration extends Object
Backend-independent additive resource-level decoration for domain writes. It is applied by the shared backend-neutral decoration phase after the basic write.

Carries only:

  • ResourceObject.links, and
  • per-relationship Relationship.links for existing mapped relationships
It never replaces type, id/lid, attributes, relationship linkage/data, resource meta, relationship meta, identifier meta, inclusion membership, or sparse-fieldset provenance, and it never creates a relationship that normal mapping did not produce. Relationship entries are keyed by the logical application-property identity — the Jackson logical name (e.g. "comments" for a Java field named comments) — not the configured-Jackson external property name (e.g. @JsonProperty("article-comments")) and not a separately supplied final JSON:API member name. The mapper translates the identity through the configured external name and applies each entry under the final wire member name automatically, so @JsonProperty("article-comments") does not require a second key.

Decoration is immutable: the relationship map is defensively copied and unmodifiable. Null keys, null values, and empty property names are rejected. Use builder() for incremental assembly or empty() when no decoration is needed.

  • Method Details

    • empty

      public static ResourceDecoration empty()
      Returns an empty decoration (no resource links, no relationship decorations).
    • ofLinks

      public static ResourceDecoration ofLinks(com.kazforge.jsonapi.core.model.Links links)
      Returns a decoration that contributes only resource links.
    • builder

      public static ResourceDecoration.Builder builder()
      Creates a builder for one immutable decoration.
    • links

      public @Nullable com.kazforge.jsonapi.core.model.Links links()
      Resource links to add, or null when none.
    • relationships

      public Map<String,RelationshipDecoration> relationships()
      Relationship decorations by mapped property identity (logical name), unmodifiable. Values are never null; keys are never null or empty.
    • isEmpty

      public boolean isEmpty()
      Returns true when this decoration carries neither resource nor relationship links. A present-empty Links (Links.empty() / "links":{}) is a wire-visible value and is not considered empty; only null means absence.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object