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

io.tarantool.driver.mappers.DefaultMultiValueResultMapper 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;

import io.tarantool.driver.api.MultiValueCallResult;
import io.tarantool.driver.mappers.converters.ValueConverter;
import io.tarantool.driver.mappers.converters.value.ArrayValueToMultiValueCallResultSimpleConverter;
import io.tarantool.driver.mappers.factories.DefaultMessagePackMapperFactory;
import org.msgpack.value.ArrayValue;

import java.util.List;

/**
 * Default mapper for {@link MultiValueCallResult} with content types supported by the given value mapper
 *
 * @param  target result content type
 * @author Alexey Kuzin
 */
public class DefaultMultiValueResultMapper>
    extends CallResultMapper> {

    /**
     * Basic constructor
     *
     * @param valueMapper  value mapper for result content conversion
     * @param contentClass target result content class
     */
    public DefaultMultiValueResultMapper(MessagePackMapper valueMapper, Class contentClass) {
        super(DefaultMessagePackMapperFactory.getInstance().emptyMapper(),
            defaultValueConverter(valueMapper), getResultClass(contentClass));
    }

    @SuppressWarnings("unchecked")
    private static > Class> getResultClass(Class contentClass) {
        return (Class>) (Class) MultiValueCallResult.class;
    }

    private static > ValueConverter>
    defaultValueConverter(MessagePackValueMapper valueMapper) {
        return new ArrayValueToMultiValueCallResultSimpleConverter<>(valueMapper::fromValue);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy