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

io.tarantool.driver.mappers.factories.ArrayValueToTarantoolResultMapperFactory 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.TarantoolResult;
import io.tarantool.driver.mappers.MessagePackMapper;
import io.tarantool.driver.mappers.MessagePackValueMapper;
import io.tarantool.driver.mappers.TarantoolResultMapper;
import io.tarantool.driver.mappers.converters.ValueConverter;
import io.tarantool.driver.mappers.converters.value.ArrayValueToTarantoolResultConverter;
import org.msgpack.value.ArrayValue;
import org.msgpack.value.ValueType;

/**
 * Factory for {@link TarantoolResultMapper} instances used for handling results with tuples of any type
 *
 * @author Alexey Kuzin
 * @author Artyom Dubinin
 */
public class ArrayValueToTarantoolResultMapperFactory extends TarantoolResultMapperFactory {

    private final MessagePackMapper messagePackMapper;

    /**
     * Basic constructor
     */
    public ArrayValueToTarantoolResultMapperFactory() {
        this(DefaultMessagePackMapperFactory.getInstance().emptyMapper());
    }

    /**
     * Basic constructor with mapper
     *
     * @param messagePackMapper MessagePack-to-object mapper for tuple contents
     */
    public ArrayValueToTarantoolResultMapperFactory(MessagePackMapper messagePackMapper) {
        super();
        this.messagePackMapper = messagePackMapper;
    }

    /**
     * Get converter for tuples in {@link TarantoolResult}
     *
     * @param valueConverter MessagePack-to-entity converter for tuples
     * @return mapper instance
     */
    public TarantoolResultMapper withArrayValueToTarantoolResultConverter(
        ValueConverter valueConverter) {
        return withConverterWithoutTargetClass(
            messagePackMapper.copy(),
            ValueType.ARRAY,
            new ArrayValueToTarantoolResultConverter<>(valueConverter)
        );
    }

    /**
     * Get converter for tuples in {@link TarantoolResult}
     *
     * @param valueMapper    MessagePack-to-object mapper for tuple contents
     * @param valueConverter MessagePack-to-entity converter for tuples
     * @return mapper instance
     */
    public TarantoolResultMapper withArrayValueToTarantoolResultConverter(
        MessagePackValueMapper valueMapper,
        ValueConverter valueConverter) {
        return withConverter(
            valueMapper,
            ValueType.ARRAY,
            new ArrayValueToTarantoolResultConverter<>(valueConverter)
        );
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy