Interface IdentifierConverter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
One conversion authority serves both identity roles: the id role mapped by
@JsonApiId and the lid role mapped by @JsonApiLocalId. Their Java scalar
conversion semantics are equivalent; only the JSON:API member they land on differs.
Write side: implementations receive the raw identifier value from the mapped identity property
and return the string used as "id" or "lid" in the resource object. Return
null to signal a missing identifier, which causes a JsonApiMappingException with MappingDiagnostic.MISSING_IDENTIFIER at that role's wire location.
Read side: parse(String) inverts convert(Object). The flat DTO binder passes
the wire identifier string to parse(String) and coerces the returned value to the
identity property's Java type. The default implementation returns the wire string unchanged;
custom converters that alter the wire form must override parse(String) to invert that
form.
Use defaults() for the built-in toString() conversion.
-
Method Summary
Modifier and TypeMethodDescription@Nullable StringConverts a raw identifier value to its string form.static IdentifierConverterdefaults()Returns the built-in converter that delegates toObject.toString().default @Nullable ObjectParses a JSON:API identifier string back into a value for the identifier property.
-
Method Details
-
convert
Converts a raw identifier value to its string form. Anullreturn signals a missing identifier. -
parse
Parses a JSON:API identifier string back into a value for the identifier property.Called only when the resource object carries an identifier (
idorlid). The returned value is coerced to the identifier property's Java type by the binder. Anullreturn fails the bind withMappingDiagnostic.IDENTIFIER_CONVERSION_FAILED. -
defaults
Returns the built-in converter that delegates toObject.toString().
-