com.googlecode.objectify.impl.conv.CollectionConverter 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 java.util.ArrayList;
import java.util.Collection;
import com.googlecode.objectify.impl.TypeUtils;
/**
* Knows how to convert java Collections. Note that each individual element must be
* converted.
*/
public class CollectionConverter implements Converter
{
/** Need this to convert members */
Conversions conversions;
/** */
public CollectionConverter(Conversions conv)
{
this.conversions = conv;
}
@Override
public Object forDatastore(Object value, ConverterSaveContext ctx)
{
if (value instanceof Collection)
{
if (ctx.inEmbeddedCollection())
throw new IllegalStateException("You cannot have collections inside @Embedded arrays or collections");
// All collections get turned into a List that preserves the order. We must
// also be sure to convert anything contained in the collection
ArrayList