com.googlecode.objectify.impl.FieldWrapper 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;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import com.googlecode.objectify.annotation.Serialized;
/**
* Wrapper which makes a field look just like... a field. More importantly,
* we can also make methods look just like this.
*/
public class FieldWrapper implements Wrapper
{
Field field;
public FieldWrapper(Field field) { this.field = field; }
@Override
public Class getType() { return this.field.getType(); }
@Override
public Type getGenericType() { return this.field.getGenericType(); }
@Override
public void set(Object pojo, Object value)
{
try { this.field.set(pojo, value); }
catch (IllegalAccessException ex) { throw new RuntimeException(ex); }
}
@Override
public Object get(Object pojo)
{
try { return this.field.get(pojo); }
catch (IllegalAccessException ex) { throw new RuntimeException(ex); }
}
@Override
public boolean isSerialized()
{
return this.field.isAnnotationPresent(Serialized.class);
}
@Override
public String toString()
{
return this.field.toString();
}
}