Class JsonApiResourceBinder

java.lang.Object
com.kazforge.jsonapi.jackson3.JsonApiResourceBinder

public final class JsonApiResourceBinder extends Object
Binds validated JSON:API ResourceObject values to annotated flat DTO types.

Construct instances via JsonApiJackson3.resourceBinder(JsonMapper) or its overloads, never directly. The binder is safe for concurrent use once created. Binding uses the mapping definitions (resolver and cache) and one ObjectMapper.convertValue(Object, JavaType) per resource, so Jackson's logical property model, creators, deserializers, converters, naming, mix-ins, and configured modules remain authoritative. JSON:API annotations assign semantic roles; unannotated Jackson-visible properties do not participate, except the conventional identifier whose Jackson external name is id. Wire id binds only to the id role and wire lid only to the @JsonApiLocalId role; neither member ever falls back into the other role's property.

Binding is read-only and document-first: callers pass an already-validated ResourceObject and the binder never parses JSON nor reads document included. Relationship properties receive linkage only — ResourceIdentifier (and Optional, List, Set, or array variants) bind from linkage directly; any other target class requires a registered RelationshipLinkageMapper. Built-in identifier linkage preserves ResourceIdentifier.meta and still drops additional members. Write overlay of application-owned identifier meta uses opt-in RelationshipLinkage; it is not relationship-level meta.

Binding failures throw JsonApiMappingException with a stable MappingDiagnostic and a resource-relative JSON Pointer-like path.

  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    fromResource(com.kazforge.jsonapi.core.model.ResourceObject resource, Class<T> targetType)
    Binds one resource object to the given DTO type.
    fromResource(com.kazforge.jsonapi.core.model.ResourceObject resource, tools.jackson.databind.JavaType targetType)
    Binds one resource object to the given DTO Java type.
    <T> List<T>
    fromResources(List<com.kazforge.jsonapi.core.model.ResourceObject> resources, Class<T> targetType)
    Binds a homogeneous collection of resource objects to DTOs of the given type.
    fromResources(List<com.kazforge.jsonapi.core.model.ResourceObject> resources, tools.jackson.databind.JavaType targetType)
    Binds a homogeneous collection of resource objects to DTOs of the given Java type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • fromResource

      public <T> T fromResource(com.kazforge.jsonapi.core.model.ResourceObject resource, Class<T> targetType)
      Binds one resource object to the given DTO type.
    • fromResource

      public Object fromResource(com.kazforge.jsonapi.core.model.ResourceObject resource, tools.jackson.databind.JavaType targetType)
      Binds one resource object to the given DTO Java type.
    • fromResources

      public <T> List<T> fromResources(List<com.kazforge.jsonapi.core.model.ResourceObject> resources, Class<T> targetType)
      Binds a homogeneous collection of resource objects to DTOs of the given type. Every element's type must match the target's @JsonApiResource.type(); heterogeneous lists are out of scope.
    • fromResources

      public List<Object> fromResources(List<com.kazforge.jsonapi.core.model.ResourceObject> resources, tools.jackson.databind.JavaType targetType)
      Binds a homogeneous collection of resource objects to DTOs of the given Java type. Every element's type must match the target's @JsonApiResource.type().