io.tarantool.driver.mappers.factories.SingleValueWithTarantoolResultMapperFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cartridge-driver Show documentation
Show all versions of cartridge-driver Show documentation
Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework
package io.tarantool.driver.mappers.factories;
import io.tarantool.driver.api.SingleValueCallResult;
import io.tarantool.driver.api.TarantoolResult;
import io.tarantool.driver.mappers.CallResultMapper;
import io.tarantool.driver.mappers.MessagePackMapper;
import io.tarantool.driver.mappers.converters.ValueConverter;
import org.msgpack.value.ArrayValue;
/**
* Factory for {@link CallResultMapper} instances used for handling Lua call results resulting in lists of
* tuples
*
* @author Alexey Kuzin
* @author Artyom Dubinin
* @see TarantoolResult
*/
public class SingleValueWithTarantoolResultMapperFactory extends SingleValueResultMapperFactory> {
private final ArrayValueToTarantoolResultMapperFactory tarantoolResultMapperFactory;
/**
* Basic constructor
*/
public SingleValueWithTarantoolResultMapperFactory() {
super();
tarantoolResultMapperFactory = new ArrayValueToTarantoolResultMapperFactory<>();
}
/**
* Basic constructor with mapper
*
* @param messagePackMapper mapper for MessagePack entities in tuple fields to Java objects
*/
public SingleValueWithTarantoolResultMapperFactory(MessagePackMapper messagePackMapper) {
super(messagePackMapper);
tarantoolResultMapperFactory = new ArrayValueToTarantoolResultMapperFactory<>();
}
/**
* Get {@link TarantoolResult} mapper for the Lua function call with single result
*
* @param valueConverter the result content converter
* @return call result mapper
*/
public CallResultMapper, SingleValueCallResult>>
withSingleValueArrayTarantoolResultConverter(ValueConverter valueConverter) {
return withSingleValueResultConverter(
tarantoolResultMapperFactory.withArrayValueToTarantoolResultConverter(valueConverter));
}
/**
* Get {@link TarantoolResult} mapper for the Lua function call with single result
*
* @param valueConverter the result content converter
* @param resultClass full result type class
* @return call result mapper
*/
public CallResultMapper, SingleValueCallResult>>
withSingleValueArrayTarantoolResultConverter(
ValueConverter valueConverter,
Class extends SingleValueCallResult>> resultClass) {
return withSingleValueResultConverter(
tarantoolResultMapperFactory.withArrayValueToTarantoolResultConverter(valueConverter),
resultClass);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy