Package io.tarantool.driver.mappers
Class AbstractResultMapper<T>
- java.lang.Object
-
- io.tarantool.driver.mappers.AbstractResultMapper<T>
-
- Type Parameters:
T
- target result type
- All Implemented Interfaces:
MessagePackValueMapper
- Direct Known Subclasses:
CallResultMapper
,TarantoolResultMapper
public abstract class AbstractResultMapper<T> extends Object implements MessagePackValueMapper
Base class for result tuple mappers
-
-
Field Summary
Fields Modifier and Type Field Description protected MessagePackValueMapper
valueMapper
-
Constructor Summary
Constructors Constructor Description AbstractResultMapper(MessagePackValueMapper valueMapper, ValueConverter<org.msgpack.value.ArrayValue,? extends T> resultConverter, Class<? extends T> resultClass)
Basic constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <V extends org.msgpack.value.Value,O>
OfromValue(V v)
Create Java object out of its MessagePack representation.<V extends org.msgpack.value.Value,O>
OfromValue(V v, Class<O> targetClass)
Create Java object out of its MessagePack representation.<V extends org.msgpack.value.Value,O>
Optional<ValueConverter<V,O>>getValueConverter(org.msgpack.value.ValueType valueType, Class<O> objectClass)
Get a converter capable of converting from the source entity class to the target class<V extends org.msgpack.value.Value,O>
voidregisterValueConverter(org.msgpack.value.ValueType valueType, Class<? extends O> objectClass, ValueConverter<V,? extends O> converter)
Adds a MessagePack entity converter to this mappers instance.
-
-
-
Field Detail
-
valueMapper
protected final MessagePackValueMapper valueMapper
-
-
Constructor Detail
-
AbstractResultMapper
public AbstractResultMapper(MessagePackValueMapper valueMapper, ValueConverter<org.msgpack.value.ArrayValue,? extends T> resultConverter, Class<? extends T> resultClass)
Basic constructor- Parameters:
valueMapper
- MessagePack value-to-object mapper for result contentsresultConverter
- converter from MessagePack result array to result typeresultClass
- target result class
-
-
Method Detail
-
fromValue
public <V extends org.msgpack.value.Value,O> O fromValue(V v) throws MessagePackValueMapperException
Description copied from interface:MessagePackValueMapper
Create Java object out of its MessagePack representation.- Specified by:
fromValue
in interfaceMessagePackValueMapper
- Type Parameters:
V
- source MessagePack entity typeO
- target object type- Parameters:
v
- MessagePack entity- Returns:
- Java object
- Throws:
MessagePackValueMapperException
- if the corresponding conversion cannot be performed
-
fromValue
public <V extends org.msgpack.value.Value,O> O fromValue(V v, Class<O> targetClass) throws MessagePackValueMapperException
Description copied from interface:MessagePackValueMapper
Create Java object out of its MessagePack representation. Converters will be checked to match the target object type.- Specified by:
fromValue
in interfaceMessagePackValueMapper
- Type Parameters:
V
- source MessagePack entity typeO
- target object type- Parameters:
v
- MessagePack entitytargetClass
- Java object class- Returns:
- Java object
- Throws:
MessagePackValueMapperException
- if the corresponding conversion cannot be performed
-
registerValueConverter
public <V extends org.msgpack.value.Value,O> void registerValueConverter(org.msgpack.value.ValueType valueType, Class<? extends O> objectClass, ValueConverter<V,? extends O> converter)
Description copied from interface:MessagePackValueMapper
Adds a MessagePack entity converter to this mappers instance.- Specified by:
registerValueConverter
in interfaceMessagePackValueMapper
- Type Parameters:
V
- MessagePack's entity type that the converter accepts and/or returnsO
- java object's type that the converter accepts and/or returns- Parameters:
valueType
- MessagePack source typeobjectClass
- target object classconverter
- object-to-entity converter- See Also:
ValueConverter
-
getValueConverter
public <V extends org.msgpack.value.Value,O> Optional<ValueConverter<V,O>> getValueConverter(org.msgpack.value.ValueType valueType, Class<O> objectClass)
Description copied from interface:MessagePackValueMapper
Get a converter capable of converting from the source entity class to the target class- Specified by:
getValueConverter
in interfaceMessagePackValueMapper
- Type Parameters:
V
- MessagePack's entity type that the converter accepts and/or returnsO
- java object's type that the converter accepts and/or returns- Parameters:
valueType
- MessagePack source typeobjectClass
- the target conversion class- Returns:
- a nullable converter instance wrapped in
Optional
-
-