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

io.tarantool.driver.mappers.MessagePackValueMapper 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 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