com.googlecode.objectify.impl.conv.KeyConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of objectify Show documentation
Show all versions of objectify Show documentation
*** THIS VERSION UPLOADED FOR USE WITH CEDAR-COMMON, TO AVOID DEPENDENCIES ON GOOGLE CODE-BASED MAVEN REPOSITORIES. *** The simplest convenient interface to the Google App Engine datastore
The newest version!
package com.googlecode.objectify.impl.conv;
import com.googlecode.objectify.Key;
/**
* Knows how to convert Key objects to datastore-native Key objects and vice-versa.
*/
public class KeyConverter implements Converter
{
@Override
public Object forDatastore(Object value, ConverterSaveContext ctx)
{
if (value instanceof Key)
return ((Key)value).getRaw();
else
return null;
}
@Override
public Object forPojo(Object value, Class fieldType, ConverterLoadContext ctx, Object onPojo)
{
if (Key.class.isAssignableFrom(fieldType) && value instanceof com.google.appengine.api.datastore.Key)
return new Key