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

io.tarantool.driver.mappers.AbstractTarantoolResultMapper 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.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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy