Class JsonTranslator<T>
- java.lang.Object
-
- org.rootservices.otter.translator.JsonTranslator<T>
-
- Type Parameters:
T- the type to be marshalled to/from json.
public class JsonTranslator<T> extends java.lang.ObjectThere should be a instance of this class per LegacyRestResource.
-
-
Constructor Summary
Constructors Constructor Description JsonTranslator(com.fasterxml.jackson.databind.ObjectReader objectReader, com.fasterxml.jackson.databind.ObjectWriter objectWriter, java.lang.Class<T> type)
-
Method Summary
Modifier and Type Method Description Tfrom(byte[] json)TfromWithSpecificCause(byte[] json)Translates json from T.protected java.util.Optional<java.lang.String>getJsonParseExceptionDuplicateKey(com.fasterxml.jackson.core.JsonParseException e)protected voidhandleJsonParseException(com.fasterxml.jackson.core.JsonParseException jpe)byte[]to(java.lang.Object object)
-
-
-
Constructor Detail
-
JsonTranslator
public JsonTranslator(com.fasterxml.jackson.databind.ObjectReader objectReader, com.fasterxml.jackson.databind.ObjectWriter objectWriter, java.lang.Class<T> type)
-
-
Method Detail
-
from
public T from(byte[] json) throws DeserializationException
- Throws:
DeserializationException
-
fromWithSpecificCause
public T fromWithSpecificCause(byte[] json) throws InvalidPayloadException, DuplicateKeyException, UnknownKeyException, InvalidValueException
Translates json from T. If an issue occurs it throws a specific cause about what happened?- Parameters:
json- json to marshal- Returns:
- an instance of T
- Throws:
InvalidPayloadException- unpredicted error occurredDuplicateKeyException- a key was repeatedUnknownKeyException- a key was not expectedInvalidValueException- key value was incorrect for it's type
-
to
public byte[] to(java.lang.Object object) throws ToJsonException- Throws:
ToJsonException
-
handleJsonParseException
protected void handleJsonParseException(com.fasterxml.jackson.core.JsonParseException jpe) throws DuplicateKeyException, InvalidPayloadException
-
getJsonParseExceptionDuplicateKey
protected java.util.Optional<java.lang.String> getJsonParseExceptionDuplicateKey(com.fasterxml.jackson.core.JsonParseException e)
-
-