Interface RelationshipLinkageMapper

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface RelationshipLinkageMapper
Converts JSON:API relationship linkage into a value for a flat DTO relationship property.

Register implementations by target class with JsonApiJackson3.resourceBinder(tools.jackson.databind.json.JsonMapper, IdentifierConverter, java.util.Map) when a relationship property's target type is not one of the built-in ResourceIdentifier shapes. The binder invokes the mapper only for RelationshipData.SingleLinkage (to-one properties, including each occurrence of a to-many RelationshipLinkage collection) and non-empty RelationshipData.IdentifierCollectionLinkage (ordinary to-many properties); explicit null and empty linkage short-circuit without a mapper call, and to-one versus to-many cardinality is enforced before invocation.

targetType is T for to-one properties and for each wrapped to-many occurrence, or the collection type of T for ordinary to-many properties (Optional unwrapped). The returned value is placed directly into the binder's synthetic property map, so it must be coercible to targetType. A null return binds a to-one property to null. For a wrapped to-many occurrence, null is MappingDiagnostic.LINKAGE_MAPPING_FAILED: RelationshipLinkage.target() cannot be null, and omitting the wire identifier would drop a linkage entry. Wrapped to-many properties never reassociate a collection-level mapper result by index.

  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Object
    map(com.kazforge.jsonapi.core.model.RelationshipData linkage, tools.jackson.databind.JavaType targetType)
    Converts linkage to a property value, or returns null for an empty to-one value.
  • Method Details

    • map

      @Nullable Object map(com.kazforge.jsonapi.core.model.RelationshipData linkage, tools.jackson.databind.JavaType targetType)
      Converts linkage to a property value, or returns null for an empty to-one value.

      A null return for a wrapped to-many occurrence fails mapping with MappingDiagnostic.LINKAGE_MAPPING_FAILED.

      Throws:
      RuntimeException - when the linkage cannot be converted; the binder reports this as MappingDiagnostic.LINKAGE_MAPPING_FAILED