com.googlecode.objectify.impl.load.EmbeddedMultivalueSetter 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.load;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import com.googlecode.objectify.impl.FieldWrapper;
import com.googlecode.objectify.impl.LoadContext;
import com.googlecode.objectify.impl.TypeUtils;
/**
* This is a base class for handling setter operations on collections and arrays.
*/
abstract public class EmbeddedMultivalueSetter extends CollisionDetectingSetter
{
/**
* The field which holds the embedded collection. We use FieldWrapper instead of
* Field because we want to use methods that take a the wrapper type.
*/
FieldWrapper field;
/**
* The blah.blah.blah path to the embedded collection. This is used as
* a base path to discover the null values index.
*/
String path;
/** */
public EmbeddedMultivalueSetter(Field field, String path, Collection collisionPaths)
{
super(collisionPaths);
assert TypeUtils.isEmbedded(field);
assert TypeUtils.isArrayOrCollection(field.getType());
this.field = new FieldWrapper(field);
this.path = path;
}
/** @return the no-arg constructor of the embedded type */
protected abstract Constructor getComponentConstructor();
/**
* Gets the collection in the relevant field of the specified POJO, or creates (and
* sets) a new one. If the field is an array type, set it up and return a Collection
* facade of the array.
*
* @param toPojo is the entity pojo that has a field for us to set
* @param size is the size of the pojo to create, if necessary
*/
protected abstract Collection