Module org.apache.johnzon.mapper
Package org.apache.johnzon.mapper
Interface Adapter<POJO_TYPE,JSON_TYPE>
- 
- Type Parameters:
- 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.
 - All Superinterfaces:
- MapperConverter
 - All Known Subinterfaces:
- TypeAwareAdapter<A,B>
 - All Known Implementing Classes:
- ConverterAdapter,- DateWithCopyConverter,- LocaleConverter,- ReversedAdapter,- TimestampAdapter
 
 public interface Adapter<POJO_TYPE,JSON_TYPE> extends MapperConverter An Adapter is similar to aConverter. 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 itDateHolder. OurMappershould treat it as ajava.util.Date. For doing so we create aDateHolderAdapterlike the following example shows:
 Consider a POJO has a DateHolder. When serialising thepublic static class DateHolderAdapter implements Adapter<DateHolder, Date>{@Overridepublic DateHolder to(Date date) { DateHolder dh = new DateHolder(date.getTime()); return dh; }@Overridepublic Date from(DateHolder dateHolder) { return new Date(dateHolder.getDate()); } }Mapperwill first use theDateHolderAdapter#from(DateHolder)and from there to JSON. When reading JSON theto(Date)method will be used.
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description JSON_TYPEfrom(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_TYPEto(JSON_TYPE b)Transfer JSONTYPE_TYPE from JSON to POJO as POJO_TYPE.
 
-