io.tarantool.driver.mappers.factories.MultiValueResultMapperFactory 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.factories;
import io.tarantool.driver.api.MultiValueCallResult;
import io.tarantool.driver.mappers.CallResultMapper;
import io.tarantool.driver.mappers.MessagePackMapper;
import io.tarantool.driver.mappers.MessagePackValueMapper;
import io.tarantool.driver.mappers.converters.ValueConverter;
import io.tarantool.driver.mappers.converters.value.ArrayValueToMultiValueCallResultConverter;
import io.tarantool.driver.mappers.converters.value.ArrayValueToMultiValueCallResultSimpleConverter;
import org.msgpack.value.ArrayValue;
import java.util.List;
/**
* Factory for {@link CallResultMapper} instances used for handling Lua call multi-return result which is
* treated as a list of values
*
* @author Alexey Kuzin
* @author Artyom Dubinin
*/
public class MultiValueResultMapperFactory> extends
TarantoolCallResultMapperFactory> {
private final MessagePackMapper messagePackMapper;
/**
* Basic constructor
*/
public MultiValueResultMapperFactory() {
this(DefaultMessagePackMapperFactory.getInstance().emptyMapper());
}
/**
* Basic constructor with mapper
*
* @param messagePackMapper MessagePack-to-entity mapper for result contents conversion
*/
public MultiValueResultMapperFactory(MessagePackMapper messagePackMapper) {
super();
this.messagePackMapper = messagePackMapper;
}
/**
* Get result mapper for the Lua function call with multi-return result
*
* @param valueMapper MessagePack-to-entity mapper for result contents conversion
* @param itemsConverter the result list converter
* @return call result mapper
*/
public CallResultMapper> withMultiValueResultConverter(
MessagePackValueMapper valueMapper,
ValueConverter itemsConverter) {
return withConverter(valueMapper, new ArrayValueToMultiValueCallResultSimpleConverter<>(itemsConverter));
}
/**
* Get result mapper for the Lua function call with multi-return result
*
* @param itemsConverter the result list converter
* @return call result mapper
*/
public CallResultMapper> withMultiValueResultConverter(
ValueConverter itemsConverter) {
return withConverter(messagePackMapper.copy(),
new ArrayValueToMultiValueCallResultSimpleConverter<>(itemsConverter));
}
/**
* Get result mapper for the Lua function call with multi-return result
*
* @param valueMapper MessagePack-to-entity mapper for result contents conversion
* @param itemsConverter result list converter
* @param resultClass full result type class
* @return call result mapper
*/
public CallResultMapper> withMultiValueResultConverter(
MessagePackValueMapper valueMapper,
ValueConverter itemsConverter,
Class extends MultiValueCallResult> resultClass) {
return withConverter(valueMapper, new ArrayValueToMultiValueCallResultSimpleConverter<>(itemsConverter),
resultClass);
}
/**
* Get result mapper for the Lua function call with multi-return result
*
* @param itemsConverter result list converter
* @param resultClass full result type class
* @return call result mapper
*/
public CallResultMapper> withMultiValueResultConverter(
ValueConverter itemsConverter,
Class extends MultiValueCallResult> resultClass) {
return withConverter(
messagePackMapper.copy(), new ArrayValueToMultiValueCallResultSimpleConverter<>(itemsConverter),
resultClass);
}
public CallResultMapper> withMultiValueResultConverter(
MessagePackValueMapper structureValueMapper) {
return withConverter(
messagePackMapper.copy(), new ArrayValueToMultiValueCallResultConverter<>(structureValueMapper));
}
public CallResultMapper> withMultiValueResultConverter(
MessagePackValueMapper valueMapper,
MessagePackValueMapper structureValueMapper) {
return withConverter(
valueMapper, new ArrayValueToMultiValueCallResultConverter<>(structureValueMapper));
}
public CallResultMapper> withMultiValueResultConverter(
MessagePackValueMapper structureValueMapper,
Class extends MultiValueCallResult> resultClass) {
return withMultiValueResultConverter(
messagePackMapper.copy(), structureValueMapper, resultClass);
}
public CallResultMapper> withMultiValueResultConverter(
MessagePackValueMapper valueMapper,
MessagePackValueMapper structureValueMapper,
Class extends MultiValueCallResult> resultClass) {
return withConverter(
valueMapper, new ArrayValueToMultiValueCallResultConverter<>(structureValueMapper), resultClass);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy