public enum ConverterFactory extends Enum<ConverterFactory>
When storing and retrieving your own domain objects to/from Riak, they
need to be serialized / deserialized. By default the JSONConverter
is provided. This uses the Jackson JSON library to translate your object to/from
JSON. In many cases you will never need to create or register your own
converter with the ConverterFactory.
In the case you do need custom conversion, you would extend Converter
and then register it with the ConverterFactory for your classes.
Enum Constant and Description |
---|
INSTANCE |
Modifier and Type | Method and Description |
---|---|
<T> Converter<T> |
getConverter(Type type)
Returns a Converter
|
<T> Converter<T> |
getConverter(com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
Returns a Converter instance for the supplied class.
|
static ConverterFactory |
getInstance()
Get the instance of the ConverterFactory.
|
<T> void |
registerConverterForClass(Class<T> clazz,
Converter<T> converter)
Register a converter for the supplied class.
|
<T> void |
registerConverterForClass(com.fasterxml.jackson.core.type.TypeReference<T> typeReference,
Converter<T> converter)
Register a converter for the supplied class.
|
<T> void |
unregisterConverterForClass(Class<T> clazz)
Unregister a converter.
|
<T> void |
unregisterConverterForClass(com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
Unregister a converter.
|
static ConverterFactory |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ConverterFactory[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ConverterFactory INSTANCE
public static ConverterFactory[] values()
for (ConverterFactory c : ConverterFactory.values()) System.out.println(c);
public static ConverterFactory valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static ConverterFactory getInstance()
public <T> Converter<T> getConverter(Type type)
If no converter is registered, the default JSONConverter
is returned.
T
- The type for the convertertype
- The type used to look up the converterpublic <T> Converter<T> getConverter(com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
If no converter is registered, the default JSONConverter
is returned.
T
- The type for the convertertypeReference
- the TypeReference for the class being converted.public <T> void registerConverterForClass(Class<T> clazz, Converter<T> converter)
This instance be re-used for every conversion.
T
- The type being convertedclazz
- the class for this converter.converter
- an instance of Converterpublic <T> void registerConverterForClass(com.fasterxml.jackson.core.type.TypeReference<T> typeReference, Converter<T> converter)
This instance be re-used for every conversion.
T
- The type being convertedtypeReference
- the TypeReference for the class being converted.converter
- an instance of Converterpublic <T> void unregisterConverterForClass(Class<T> clazz)
T
- The typeclazz
- the class being convertedpublic <T> void unregisterConverterForClass(com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
T
- The typetypeReference
- the TypeReference for the class being converted.Copyright © 2016. All rights reserved.