com.distelli.persistence.ConvertValue Maven / Gradle / Ivy
package com.distelli.persistence;
public interface ConvertValue {
/**
* This function is called when trying to convert the results of
* Item.asMap() into the Index's parameterized class type, or
* when doing the opposite: preparing for a call to Item.fromMap().
*
* This function may also be called when using the UpdateItemBuilder
* APIs with a AttrType so the fields are properly converted to the
* desired type.
*
* Note that jackson's ObjectMapper implements this interface
* which means you can use this syntax:
*
*
* ObjectMapper om = ...;
* _indexFactory.create()
* .withConvertValue(om::convertValue)
* ...;
*
*
* @param is the type to convert into.
*
* @param from is the object to be converted.
*
* @param clazz is the type to convert to.
*
* @return the converted object.
*
* @throws Exception so the implementation is free to throw checked
* exceptions.
*/
public T convertValue(Object from, Class clazz) throws Exception;
}