com.googlecode.objectify.impl
Interface EntityMetadata<T>

All Known Implementing Classes:
ConcreteEntityMetadata, PolymorphicEntityMetadata

public interface EntityMetadata<T>

The interface by which POJOs and datastore Entity objects are translated back and forth. Subclasses implement specific mapping, including polymorphic mapping.

Author:
Jeff Schnitzer

Method Summary
 java.lang.Integer getCacheExpirySeconds()
          Get the expiry associated with this kind, defined by the @Cached annotation.
 java.lang.Class<T> getEntityClass()
          Gets the class associated with this entity.
 java.lang.String getKind()
           
 com.google.appengine.api.datastore.Key getRawKey(java.lang.Object obj)
          Gets a key composed of the relevant id and parent fields in the object.
 boolean hasParentField()
           
 boolean isIdField(java.lang.String propertyName)
           
 boolean isNameField(java.lang.String propertyName)
           
 void setKey(T obj, com.google.appengine.api.datastore.Key key)
          Sets the relevant id and parent fields of the object to the values stored in the key.
 com.google.appengine.api.datastore.Entity toEntity(T pojo, Objectify ofy)
          Converts an object to a datastore Entity with the appropriate Key type.
 T toObject(com.google.appengine.api.datastore.Entity ent, Objectify ofy)
          Converts an entity to an object of the appropriate type for this metadata structure.
 

Method Detail

getKind

java.lang.String getKind()
Returns:
the datastore kind associated with this metadata

getCacheExpirySeconds

java.lang.Integer getCacheExpirySeconds()
Get the expiry associated with this kind, defined by the @Cached annotation. For polymorphic types, this is always the instruction on the root @Entity - you cannot provide per-type caching.

Returns:
null means DO NOT CACHE, 0 means "no limit", otherwise # of seconds

toObject

T toObject(com.google.appengine.api.datastore.Entity ent,
           Objectify ofy)
Converts an entity to an object of the appropriate type for this metadata structure. Does not check that the entity is appropriate; that should be done when choosing which EntityMetadata to call.


toEntity

com.google.appengine.api.datastore.Entity toEntity(T pojo,
                                                   Objectify ofy)
Converts an object to a datastore Entity with the appropriate Key type.


setKey

void setKey(T obj,
            com.google.appengine.api.datastore.Key key)
Sets the relevant id and parent fields of the object to the values stored in the key.

Parameters:
obj - must be of the entityClass type for this metadata.

getRawKey

com.google.appengine.api.datastore.Key getRawKey(java.lang.Object obj)
Gets a key composed of the relevant id and parent fields in the object.

Parameters:
obj - must be of the entityClass type for this metadata.
Throws:
java.lang.IllegalArgumentException - if obj has a null id

isIdField

boolean isIdField(java.lang.String propertyName)
Returns:
true if the property name corresponds to a Long/long @Id field. If the entity has a String name @Id, this will return false.

isNameField

boolean isNameField(java.lang.String propertyName)
Returns:
true if the property name corresponds to a String @Id field. If the entity has a Long/long @Id, this will return false.

hasParentField

boolean hasParentField()
Returns:
true if the entity has a parent field

getEntityClass

java.lang.Class<T> getEntityClass()
Gets the class associated with this entity. For concrete metadata it will be the actual class; for polymorphic metadata this will be the base class.



Copyright © 2011 Jeff Schnitzer and a gang of pirates. All Rights Reserved. Build version: 3.1