io.tarantool.driver.mappers.AbstractTarantoolResultMapper 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.TarantoolResultImpl;
import org.msgpack.value.ArrayValue;
import org.msgpack.value.Value;
import java.util.Optional;
/**
* Base class for TarantoolResult tuple mappers
*
* @param target tuple type
* @author Alexey Kuzin
*/
public abstract class AbstractTarantoolResultMapper implements MessagePackValueMapper {
protected final MessagePackValueMapper valueMapper;
public AbstractTarantoolResultMapper(MessagePackValueMapper valueMapper,
ValueConverter tarantoolResultConverter) {
this.valueMapper = valueMapper;
valueMapper.registerValueConverter(ArrayValue.class, TarantoolResultImpl.class, tarantoolResultConverter);
}
@Override
public O fromValue(V v) throws MessagePackValueMapperException {
return valueMapper.fromValue(v);
}
@Override
public O fromValue(V v, Class targetClass) throws MessagePackValueMapperException {
return valueMapper.fromValue(v, targetClass);
}
@Override
public void registerValueConverter(Class valueClass,
Class objectClass,
ValueConverter converter) {
valueMapper.registerValueConverter(valueClass, objectClass, converter);
}
@Override
public Optional> getValueConverter(Class entityClass,
Class objectClass) {
return valueMapper.getValueConverter(entityClass, objectClass);
}
}