
io.tarantool.driver.mappers.MessagePackValueMapper 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;
import java.util.Optional;
/**
* Basic interface for collection of generic converters between MessagePack entities and Java objects.
* Value converters must be added using the {@link #registerValueConverter(Class, Class, ValueConverter)} method
*
* @author Alexey Kuzin
*/
public interface MessagePackValueMapper extends Cloneable {
/**
* Create Java object out of its MessagePack representation.
* @param v MessagePack entity
* @param source MessagePack entity type
* @param target object type
* @return Java object
* @throws MessagePackValueMapperException if the corresponding conversion cannot be performed
*/
O fromValue(V v) throws MessagePackValueMapperException;
/**
* Create Java object out of its MessagePack representation. Converters will be checked to match the target
* object type.
* @param v MessagePack entity
* @param targetClass Java object class
* @param source MessagePack entity type
* @param target object type
* @return Java object
* @throws MessagePackValueMapperException if the corresponding conversion cannot be performed
*/
O fromValue(V v, Class targetClass) throws MessagePackValueMapperException;
/**
* Adds a MessagePack entity converter to this mappers instance.
* @param valueClass source entity class
* @param objectClass target object class
* @param converter object-to-entity converter
* @param source MessagePack entity type
* @param target object type
* @see ValueConverter
*/
void registerValueConverter(Class valueClass, Class objectClass,
ValueConverter converter);
/**
* Get a converter capable of converting from the source entity class to the target class
* @param entityClass the source entity class
* @param objectClass the target conversion class
* @param source MessagePack entity type
* @param target object type
* @return a nullable converter instance wrapped in {@code Optional}
*/
Optional> getValueConverter(Class entityClass, Class objectClass);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy