public class ResourceConverter extends Object
| Constructor and Description |
|---|
ResourceConverter(Class<?>... classes)
Creates new ResourceConverter.
|
ResourceConverter(com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<?>... classes) |
ResourceConverter(com.fasterxml.jackson.databind.ObjectMapper mapper,
String baseURL,
Class<?>... classes)
Creates new ResourceConverter.
|
ResourceConverter(String baseURL,
Class<?>... classes)
Creates new ResourceConverter.
|
| Modifier and Type | Method and Description |
|---|---|
void |
disableDeserializationOption(DeserializationFeature option)
Removes (disables) existing deserialization option.
|
void |
disableSerializationOption(SerializationFeature option)
Removes (disables) existing serialization option.
|
void |
enableDeserializationOption(DeserializationFeature option)
Adds (enables) new deserialization option.
|
void |
enableSerializationOption(SerializationFeature option)
Adds (enables) new serialization option.
|
boolean |
isRegisteredType(Class<?> type)
Checks if provided type is registered with this converter instance.
|
<T> JSONAPIDocument<T> |
readDocument(byte[] data,
Class<T> clazz)
Reads JSON API spec document and converts it into target type.
|
<T> JSONAPIDocument<T> |
readDocument(InputStream dataStream,
Class<T> clazz)
Reads JSON API spec document and converts it into target type.
|
<T> JSONAPIDocument<List<T>> |
readDocumentCollection(byte[] data,
Class<T> clazz)
Reads JSON API spec document and converts it into collection of target type objects.
|
<T> JSONAPIDocument<List<T>> |
readDocumentCollection(InputStream dataStream,
Class<T> clazz)
Reads JSON API spec document and converts it into collection of target type objects.
|
<T> T |
readObject(byte[] data,
Class<T> clazz)
Deprecated.
|
<T> List<T> |
readObjectCollection(byte[] data,
Class<T> clazz)
Deprecated.
|
boolean |
registerType(Class<?> type)
Registers new type to be used with this converter instance.
|
void |
setGlobalResolver(RelationshipResolver resolver)
Registers global relationship resolver.
|
void |
setTypeResolver(RelationshipResolver resolver,
Class<?> type)
Registers relationship resolver for given type.
|
byte[] |
writeDocument(JSONAPIDocument<?> document)
Serializes provided
JSONAPIDocument into JSON API Spec compatible byte representation. |
byte[] |
writeDocument(JSONAPIDocument<?> document,
SerializationSettings settings)
Serializes provided
JSONAPIDocument into JSON API Spec compatible byte representation. |
byte[] |
writeDocumentCollection(JSONAPIDocument<? extends Iterable<?>> documentCollection)
Serializes provided
JSONAPIDocument into JSON API Spec compatible byte representation. |
byte[] |
writeDocumentCollection(JSONAPIDocument<? extends Iterable<?>> documentCollection,
SerializationSettings serializationSettings)
Serializes provided
JSONAPIDocument into JSON API Spec compatible byte representation. |
byte[] |
writeObject(Object object)
Deprecated.
|
<T> byte[] |
writeObjectCollection(Iterable<T> objects)
Deprecated.
use writeDocumentCollection instead
|
public ResourceConverter(Class<?>... classes)
All classes that should be handled by instance of ResourceConverter must be registered
when creating a new instance of it.
classes - Class array of classes to be handled by this resource converter instancepublic ResourceConverter(String baseURL, Class<?>... classes)
All classes that should be handled by instance of ResourceConverter must be registered
when creating a new instance of it.
public ResourceConverter(com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<?>... classes)
public void setGlobalResolver(RelationshipResolver resolver)
included section and relationship resolving is enabled
trough relationship annotation. resolver - resolver instancepublic void setTypeResolver(RelationshipResolver resolver, Class<?> type)
resolver - resolver instancetype - type@Deprecated public <T> T readObject(byte[] data, Class<T> clazz)
T - typedata - raw dataclazz - target objectRuntimeException - in case conversion fails@Deprecated public <T> List<T> readObjectCollection(byte[] data, Class<T> clazz)
T - typedata - raw data inputclazz - target typeRuntimeException - in case conversion failspublic <T> JSONAPIDocument<T> readDocument(byte[] data, Class<T> clazz)
T - typedata - byte raw data (server response)clazz - Class target typeJSONAPIDocumentpublic <T> JSONAPIDocument<T> readDocument(InputStream dataStream, Class<T> clazz)
T - typedataStream - byte raw dataStream (server response)clazz - Class target typeJSONAPIDocumentpublic <T> JSONAPIDocument<List<T>> readDocumentCollection(byte[] data, Class<T> clazz)
T - typedata - byte raw data (server response)clazz - Class target typeJSONAPIDocumentpublic <T> JSONAPIDocument<List<T>> readDocumentCollection(InputStream dataStream, Class<T> clazz)
T - typedataStream - InputStream input streamclazz - Class target typeJSONAPIDocument@Deprecated public byte[] writeObject(Object object) throws com.fasterxml.jackson.core.JsonProcessingException, IllegalAccessException
object - input objectcom.fasterxml.jackson.core.JsonProcessingExceptionIllegalAccessExceptionpublic byte[] writeDocument(JSONAPIDocument<?> document) throws DocumentSerializationException
JSONAPIDocument into JSON API Spec compatible byte representation.document - JSONAPIDocument document to serializeDocumentSerializationException - thrown in case serialization failspublic byte[] writeDocument(JSONAPIDocument<?> document, SerializationSettings settings) throws DocumentSerializationException
JSONAPIDocument into JSON API Spec compatible byte representation.document - JSONAPIDocument document to serializesettings - SerializationSettings settings that override global serialization settingsDocumentSerializationException - thrown in case serialization failspublic byte[] writeDocumentCollection(JSONAPIDocument<? extends Iterable<?>> documentCollection) throws DocumentSerializationException
JSONAPIDocument into JSON API Spec compatible byte representation.documentCollection - JSONAPIDocument document collection to serializeDocumentSerializationException - thrown in case serialization failspublic byte[] writeDocumentCollection(JSONAPIDocument<? extends Iterable<?>> documentCollection, SerializationSettings serializationSettings) throws DocumentSerializationException
JSONAPIDocument into JSON API Spec compatible byte representation.documentCollection - JSONAPIDocument document collection to serializeserializationSettings - SerializationSettings settings that override global serialization settingsDocumentSerializationException - thrown in case serialization fails@Deprecated public <T> byte[] writeObjectCollection(Iterable<T> objects) throws com.fasterxml.jackson.core.JsonProcessingException, IllegalAccessException
objects - List of input objectscom.fasterxml.jackson.core.JsonProcessingExceptionIllegalAccessExceptionpublic boolean isRegisteredType(Class<?> type)
type - class to checktrue if type is registered, else falsepublic boolean registerType(Class<?> type)
type - Class type to registertrue if type was registed, else false (in case type was registered already or
type is not eligible for registering ie. missing required annotations)public void enableDeserializationOption(DeserializationFeature option)
option - DeserializationFeature optionpublic void disableDeserializationOption(DeserializationFeature option)
option - DeserializationFeature feature to disablepublic void enableSerializationOption(SerializationFeature option)
option - SerializationFeature optionpublic void disableSerializationOption(SerializationFeature option)
option - SerializationFeature feature to disableCopyright © 2017. All rights reserved.