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

io.tarantool.driver.mappers.factories.MultiValueWithTarantoolResultMapperFactory 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.MultiValueCallResult;
import io.tarantool.driver.api.TarantoolResult;
import io.tarantool.driver.mappers.CallResultMapper;
import io.tarantool.driver.mappers.MessagePackMapper;
import io.tarantool.driver.mappers.MessagePackValueMapper;
import io.tarantool.driver.mappers.converters.ValueConverter;
import org.msgpack.value.ArrayValue;

/**
 * Factory for {@link CallResultMapper} instances used for handling Lua call multi-return result items as list of
 * tuples
 *
 * @author Alexey Kuzin
 * @author Artyom Dubinin
 * @see TarantoolResult
 */
public class MultiValueWithTarantoolResultMapperFactory
    extends MultiValueResultMapperFactory> {

    private final ArrayValueToTarantoolResultMapperFactory tarantoolResultMapperFactory;

    /**
     * Basic constructor
     */
    public MultiValueWithTarantoolResultMapperFactory() {
        super();
        tarantoolResultMapperFactory = new ArrayValueToTarantoolResultMapperFactory<>();
    }

    /**
     * Basic constructor with mapper
     *
     * @param messagePackMapper MessagePack-to-entity mapper for result contents conversion
     */
    public MultiValueWithTarantoolResultMapperFactory(MessagePackMapper messagePackMapper) {
        super(messagePackMapper);
        tarantoolResultMapperFactory = new ArrayValueToTarantoolResultMapperFactory<>();
    }

    /**
     * Get {@link TarantoolResult} mapper for the Lua function call with single result
     *
     * @param valueMapper    MessagePack-to-entity mapper for result contents conversion
     * @param valueConverter the result content converter
     * @return call result mapper
     */
    public CallResultMapper, MultiValueCallResult>>
    withMultiValueArrayTarantoolResultConverter(
        MessagePackValueMapper valueMapper, ValueConverter valueConverter) {
        return withMultiValueResultConverter(valueMapper,
            tarantoolResultMapperFactory.withArrayValueToTarantoolResultConverter(valueConverter));
    }

    /**
     * Get {@link TarantoolResult} mapper for the Lua function call with single result
     *
     * @param valueConverter the result content converter
     * @return call result mapper
     */
    public CallResultMapper, MultiValueCallResult>>
    withMultiValueArrayTarantoolResultConverter(ValueConverter valueConverter) {
        return withMultiValueResultConverter(
            tarantoolResultMapperFactory.withArrayValueToTarantoolResultConverter(valueConverter));
    }

    /**
     * Get {@link TarantoolResult} mapper for the Lua function call with single result
     *
     * @param valueMapper    MessagePack-to-entity mapper for result contents conversion
     * @param valueConverter the result content converter
     * @param resultClass    full result type class
     * @return call result mapper
     */
    public CallResultMapper, MultiValueCallResult>>
    withMultiValueArrayTarantoolResultConverter(
        MessagePackValueMapper valueMapper,
        ValueConverter valueConverter,
        Class>> resultClass) {
        return withMultiValueResultConverter(
            valueMapper, tarantoolResultMapperFactory.withArrayValueToTarantoolResultConverter(valueConverter),
            resultClass);
    }

    /**
     * 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, MultiValueCallResult>>
    withMultiValueArrayTarantoolResultConverter(
        ValueConverter valueConverter,
        Class>> resultClass) {
        return withMultiValueResultConverter(
            tarantoolResultMapperFactory.withArrayValueToTarantoolResultConverter(valueConverter), resultClass);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy