io.tarantool.driver.mappers.MessagePackObjectMapper 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.Value;
/**
* Basic interface for generic converters between Java objects and MessagePack entities.
* Object converters must be added using the {@link #registerObjectConverter(Class, Class, ObjectConverter)} method
*
* @author Alexey Kuzin
*/
public interface MessagePackObjectMapper {
/**
* Create MessagePack entity representation for an object.
* @param o an object to be converted
* @param the target MessagePack entity type
* @param the source object type
* @throws MessagePackObjectMapperException if the corresponding conversion cannot be performed
* @return instance of MessagePack {@link Value}
*/
V toValue(O o) throws MessagePackObjectMapperException;
/**
* Adds a Java object converter to this mappers instance
* @param objectClass source object class
* @param valueClass target value class
* @param converter entity-to-object converter
* @param the target MessagePack entity type
* @param the source object type
* @see ObjectConverter
*/
void registerObjectConverter(Class objectClass, Class valueClass,
ObjectConverter converter);
}