org.simpleds.converter
Class AbstractCollectionConverter<C extends java.util.Collection>

java.lang.Object
  extended by org.simpleds.converter.AbstractCollectionConverter<C>
Type Parameters:
C -
All Implemented Interfaces:
CollectionConverter<C>, Converter<C,C>
Direct Known Subclasses:
ListConverter, SetConverter, SortedSetConverter

public abstract class AbstractCollectionConverter<C extends java.util.Collection>
extends java.lang.Object
implements CollectionConverter<C>

Collection converter


Constructor Summary
protected AbstractCollectionConverter(java.lang.Class<C> collectionType)
           
 
Method Summary
 C datastoreToJava(C dsValue)
          Convert a value from Google representation to a Java value
 java.lang.Class<C> getDatastoreType()
           
 Converter getItemConverter()
           
 java.lang.Class<?> getItemType()
           
 java.lang.Class<C> getJavaType()
           
 C getNullValue()
          Return the value to use for null values.
 java.lang.Object itemDatastoreToJava(java.lang.Object value)
          Convert one collection item from Google representation to a Java value
 java.lang.Object itemJavaToDatastore(java.lang.Object value)
          Convert one collection item from Java representation to a Datastore value
 C javaToDatastore(C javaValue)
          Convert a value from Java representation to a Datastore value
 void setItemConverter(Converter itemConverter)
           
 void setItemType(java.lang.Class<?> itemType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.simpleds.converter.CollectionConverter
createCollection
 

Constructor Detail

AbstractCollectionConverter

protected AbstractCollectionConverter(java.lang.Class<C> collectionType)
Method Detail

datastoreToJava

public C datastoreToJava(C dsValue)
Description copied from interface: Converter
Convert a value from Google representation to a Java value

Specified by:
datastoreToJava in interface Converter<C extends java.util.Collection,C extends java.util.Collection>
Parameters:
dsValue - the value persistent in the google datastore

getNullValue

public C getNullValue()
Description copied from interface: Converter
Return the value to use for null values. This method will usually return null, except for embedded primitive values (int, long, etc) that will return zero instead.

Specified by:
getNullValue in interface Converter<C extends java.util.Collection,C extends java.util.Collection>
Returns:
The value to use in Java in case the datastore value is null.

javaToDatastore

public C javaToDatastore(C javaValue)
Description copied from interface: Converter
Convert a value from Java representation to a Datastore value

Specified by:
javaToDatastore in interface Converter<C extends java.util.Collection,C extends java.util.Collection>
Parameters:
javaValue - the Java property value

itemDatastoreToJava

public java.lang.Object itemDatastoreToJava(java.lang.Object value)
Description copied from interface: CollectionConverter
Convert one collection item from Google representation to a Java value

Specified by:
itemDatastoreToJava in interface CollectionConverter<C extends java.util.Collection>
Parameters:
value - the value persistent in the google datastore

itemJavaToDatastore

public java.lang.Object itemJavaToDatastore(java.lang.Object value)
Description copied from interface: CollectionConverter
Convert one collection item from Java representation to a Datastore value

Specified by:
itemJavaToDatastore in interface CollectionConverter<C extends java.util.Collection>
Parameters:
value - the Java property value

getItemType

public java.lang.Class<?> getItemType()
Specified by:
getItemType in interface CollectionConverter<C extends java.util.Collection>
Returns:
the expected type of the collection items

getItemConverter

public Converter getItemConverter()

setItemConverter

public void setItemConverter(Converter itemConverter)

setItemType

public void setItemType(java.lang.Class<?> itemType)

getJavaType

public java.lang.Class<C> getJavaType()
Specified by:
getJavaType in interface Converter<C extends java.util.Collection,C extends java.util.Collection>
Returns:
the java type handled by this converter

getDatastoreType

public java.lang.Class<C> getDatastoreType()
Specified by:
getDatastoreType in interface Converter<C extends java.util.Collection,C extends java.util.Collection>
Returns:
the datastore type handled by this converter