Class JsonApiResourceBinder
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 TypeMethodDescription<T> TfromResource(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.
-
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'stypemust 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'stypemust match the target's@JsonApiResource.type().
-