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

io.tarantool.driver.mappers.factories.RowsMetadataToTarantoolTupleResultMapperFactory 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.metadata.TarantoolSpaceMetadata;
import io.tarantool.driver.api.tuple.TarantoolTuple;
import io.tarantool.driver.core.metadata.RowsMetadataToTarantoolTupleResultConverter;
import io.tarantool.driver.mappers.MessagePackMapper;
import io.tarantool.driver.mappers.MessagePackValueMapper;
import io.tarantool.driver.mappers.TarantoolResultMapper;
import io.tarantool.driver.mappers.converters.value.ArrayValueToTarantoolTupleConverter;
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 RowsMetadataToTarantoolTupleResultMapperFactory
    extends TarantoolResultMapperFactory {

    private final MessagePackMapper messagePackMapper;

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

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

    public TarantoolResultMapper withRowsMetadataToTarantoolTupleResultConverter(
        MessagePackMapper messagePackMapper) {
        return withRowsMetadataToTarantoolTupleResultConverter(
            new ArrayValueToTarantoolTupleConverter(messagePackMapper, null));
    }

    public TarantoolResultMapper withRowsMetadataToTarantoolTupleResultConverter(
        MessagePackMapper messagePackMapper, TarantoolSpaceMetadata spaceMetadata) {
        return withRowsMetadataToTarantoolTupleResultConverter(
            new ArrayValueToTarantoolTupleConverter(messagePackMapper, spaceMetadata));
    }

    public TarantoolResultMapper withRowsMetadataToTarantoolTupleResultConverter(
        ArrayValueToTarantoolTupleConverter tupleConverter) {
        return withConverterWithoutTargetClass(
            messagePackMapper.copy(),
            ValueType.MAP,
            new RowsMetadataToTarantoolTupleResultConverter(tupleConverter)
        );
    }

    public TarantoolResultMapper withRowsMetadataToTarantoolTupleResultConverter(
        MessagePackValueMapper valueMapper,
        ArrayValueToTarantoolTupleConverter tupleConverter) {
        return withConverterWithoutTargetClass(
            valueMapper,
            ValueType.MAP,
            new RowsMetadataToTarantoolTupleResultConverter(tupleConverter)
        );
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy