Package org.dominokit.jacksonapt
Class AbstractObjectMapper<T>
java.lang.Object
org.dominokit.jacksonapt.AbstractObjectMapper<T>
- All Implemented Interfaces:
ObjectMapper<T>,ObjectReader<T>,ObjectWriter<T>
- Direct Known Subclasses:
AbstractObjectReader,AbstractObjectWriter
public abstract class AbstractObjectMapper<T> extends java.lang.Object implements ObjectMapper<T>
Base implementation of
ObjectMapper. It delegates the serialization/deserialization to a serializer/deserializer.- Version:
- $Id: $
- Author:
- Nicolas Morel
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractObjectMapper(java.lang.String rootName)Constructor for AbstractObjectMapper. -
Method Summary
Modifier and Type Method Description JsonDeserializer<T>getDeserializer()getDeserializer.JsonSerializer<T>getSerializer()getSerializer.protected abstract JsonDeserializer<T>newDeserializer()Instantiates a new deserializerprotected abstract JsonSerializer<?>newSerializer()Instantiates a new serializerTread(java.lang.String in)Reads a JSON input into an object.Tread(java.lang.String in, JsonDeserializationContext ctx)Reads a JSON input into an object.T[]readArray(java.lang.String input, ArrayJsonDeserializer.ArrayCreator<T> arrayCreator)Reads a JSON input into an array object.T[]readArray(java.lang.String input, JsonDeserializationContext ctx, ArrayJsonDeserializer.ArrayCreator<T> arrayCreator)Reads a JSON input into an array object.java.lang.Stringwrite(T value)Writes an object to JSON.java.lang.Stringwrite(T value, JsonSerializationContext ctx)Writes an object to JSON.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
AbstractObjectMapper
protected AbstractObjectMapper(java.lang.String rootName)Constructor for AbstractObjectMapper.
- Parameters:
rootName- aStringobject.
-
-
Method Details
-
read
Reads a JSON input into an object.- Specified by:
readin interfaceObjectReader<T>- Parameters:
in- JSON input to read- Returns:
- the read object
- Throws:
JsonDeserializationException- if an exception occurs while reading the input
-
read
public T read(java.lang.String in, JsonDeserializationContext ctx) throws JsonDeserializationExceptionReads a JSON input into an object.- Specified by:
readin interfaceObjectReader<T>- Parameters:
in- JSON input to readctx- Context for the full reading process- Returns:
- the read object
- Throws:
JsonDeserializationException- if an exception occurs while reading the input
-
readArray
public T[] readArray(java.lang.String input, ArrayJsonDeserializer.ArrayCreator<T> arrayCreator) throws JsonDeserializationExceptionReads a JSON input into an array object.- Specified by:
readArrayin interfaceObjectReader<T>- Parameters:
input- JSON input to readarrayCreator- Creator for initializing new instance of an array of specific length- Returns:
- the read array object
- Throws:
JsonDeserializationException- if an exception occurs while reading the input
-
readArray
public T[] readArray(java.lang.String input, JsonDeserializationContext ctx, ArrayJsonDeserializer.ArrayCreator<T> arrayCreator) throws JsonDeserializationExceptionReads a JSON input into an array object.- Specified by:
readArrayin interfaceObjectReader<T>- Parameters:
input- JSON input to readctx- Context for the full reading processarrayCreator- Creator for initializing new instance of an array of specific length- Returns:
- the read array object
- Throws:
JsonDeserializationException- if an exception occurs while reading the input
-
getDeserializer
getDeserializer.
Getter for the field
deserializer.- Specified by:
getDeserializerin interfaceObjectReader<T>- Returns:
- a
JsonDeserializerobject.
-
newDeserializer
Instantiates a new deserializer- Returns:
- a new deserializer
-
write
Writes an object to JSON.- Specified by:
writein interfaceObjectWriter<T>- Parameters:
value- Object to write- Returns:
- the JSON output
- Throws:
JsonSerializationException- if an exception occurs while writing the output
-
write
public java.lang.String write(T value, JsonSerializationContext ctx) throws JsonSerializationExceptionWrites an object to JSON.- Specified by:
writein interfaceObjectWriter<T>- Parameters:
value- Object to writectx- Context for the full writing process- Returns:
- a
Stringobject. - Throws:
JsonSerializationException- if an exception occurs while writing the output
-
getSerializer
getSerializer.
Getter for the field
serializer.- Specified by:
getSerializerin interfaceObjectWriter<T>- Returns:
- a
JsonSerializerobject.
-
newSerializer
Instantiates a new serializer- Returns:
- a new serializer
-