io.tarantool.driver.mappers.DefaultMultiValueResultMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cartridge-driver Show documentation
Show all versions of cartridge-driver Show documentation
Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework
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