io.tarantool.driver.mappers.DefaultSingleValueResultMapper 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.SingleValueCallResult;
import io.tarantool.driver.mappers.converters.ValueConverter;
import io.tarantool.driver.mappers.converters.value.ArrayValueToSingleValueCallResultSimpleConverter;
import io.tarantool.driver.mappers.factories.DefaultMessagePackMapperFactory;
import org.msgpack.value.ArrayValue;
/**
* Default mapper for {@link SingleValueCallResult} with content types supported by the given value mapper
*
* @param target result content type
* @author Alexey Kuzin
*/
public class DefaultSingleValueResultMapper extends CallResultMapper> {
/**
* Basic constructor
*
* @param valueMapper value mapper for result content conversion
* @param contentClass target result content class
*/
public DefaultSingleValueResultMapper(MessagePackMapper valueMapper, Class contentClass) {
super(DefaultMessagePackMapperFactory.getInstance().emptyMapper(),
defaultValueConverter(valueMapper), getResultClass(contentClass));
}
@SuppressWarnings("unchecked")
private static Class> getResultClass(Class contentClass) {
return (Class>) (Class>) SingleValueCallResult.class;
}
private static ValueConverter> defaultValueConverter(
MessagePackValueMapper valueMapper) {
return new ArrayValueToSingleValueCallResultSimpleConverter<>(valueMapper::fromValue);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy