org.randombits.confluence.metadata.impl.handler.MapHandler Maven / Gradle / Ivy
package org.randombits.confluence.metadata.impl.handler;
import org.randombits.confluence.metadata.MetadataManager;
import org.randombits.confluence.metadata.TypeConversionException;
import org.randombits.confluence.metadata.TypeHandler;
import java.util.HashMap;
import java.util.Map;
/**
* Handles converting objects stored inside Maps to and from 'storable' instances.
*/
public class MapHandler implements TypeHandler {
private final MetadataManager metadataManager;
public MapHandler(MetadataManager metadataManager) {
this.metadataManager = metadataManager;
}
public boolean supportsOriginal( Object original ) {
return original instanceof Map;
}
public boolean supportsStorable( Object stored ) {
return stored instanceof Map;
}
public Object getOriginal( Object stored ) throws TypeConversionException {
Map, ?> storedMap = (Map, ?>) stored;
Map