POJO_TYPE
- The Java type in the POJO (Plain Old Java Object)JSON_TYPE
- The Java Type which will be used to transform to JSON.public interface Adapter<POJO_TYPE,JSON_TYPE> extends MapperConverter
Converter
.
The main difference is that a Converter always converts from/to a String.
An adapter might e.g. convert to a Date or any other Object which will
then be json-ified.
A small example which has a special Java type to internally represent dates.
Let's call it DateHolder
.
Our Mapper
should treat it as a java.util.Date
.
For doing so we create a DateHolderAdapter
like the following example shows:
public static class DateHolderAdapter implements Adapter{
Modifier and Type | Method and Description |
---|---|
JSON_TYPE |
from(POJO_TYPE a)
Take the POJO_TYPE object A from a POJO an convert it to JSON_TYPE which will be inserted into the JSON output.
|
POJO_TYPE |
to(JSON_TYPE b)
Transfer JSONTYPE_TYPE from JSON to POJO as POJO_TYPE.
|
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.