All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tarantool.driver.mappers.factories.SingleValueWithTarantoolResultMapperFactory Maven / Gradle / Ivy

Go to download

Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework

There is a newer version: 0.14.0
Show newest version
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>> resultClass) {
        return withSingleValueResultConverter(
            tarantoolResultMapperFactory.withArrayValueToTarantoolResultConverter(valueConverter),
            resultClass);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy