io.tarantool.driver.mappers.DefaultMapValueConverter 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 org.msgpack.value.MapValue;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Default {@link MapValue} converter to {@link Map} converter
*
* @author Alexey Kuzin
*/
public class DefaultMapValueConverter implements ValueConverter> {
private MessagePackValueMapper mapper;
public DefaultMapValueConverter(MessagePackValueMapper mapper) {
this.mapper = mapper;
}
@Override
public Map, ?> fromValue(MapValue value) {
return value.map().entrySet().stream()
.collect(Collectors.toMap(e -> mapper.fromValue(e.getKey()), e -> mapper.fromValue(e.getValue())));
}
}