|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.googlecode.objectify.impl.Transmog<T>
public class Transmog<T>
Class which knows how to load data from Entity to POJO and save data from POJO to Entity.
Note that this class completely ignores @Id and @Parent fields.
To understand this code, you must first understand that a "leaf" value is anything that can be put into the datastore in a single property. Simple types like String, and Enum, and Key are leaf nodes, but so are Collections and arrays of these basic types. @Embedded values are nonleaf - they branch the persistance graph, producing multiple properties in a datastore Entity.
Also realize that there are two separate dimensions to understand. Misunderstanding the two related graphs will make this code very confusing:
The core structures that operate at runtime are Setters (for loading datastore Entities into typed pojos) and Savers (for saving the fields of typed pojos into datastore Entities). They are NOT parallel hierarchies, and they work very differently:
rootSetters
, a map of entity property
name to a Setter which knows what to do with that data.rootSaver
, which
understands the whole pojo object graph and knows how to translate it into a number of properties
on the Entity.
Constructor Summary | |
---|---|
Transmog(Conversions conversions,
java.lang.Class<T> clazz)
Creats a transmog for the specified class, introspecting it and discovering how to load/save its properties. |
Method Summary | |
---|---|
void |
load(com.google.appengine.api.datastore.Entity fromEntity,
T toPojo)
Loads the property data in an Entity into a POJO. |
void |
loadSingleValue(java.lang.String key,
java.lang.Object value,
java.lang.Object toPojo,
LoadContext context)
Loads the single value value into toPojo using key as the key within
the entity. |
void |
save(T fromPojo,
com.google.appengine.api.datastore.Entity toEntity)
Saves the fields of a POJO into the properties of an Entity. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Transmog(Conversions conversions, java.lang.Class<T> clazz)
Method Detail |
---|
public void load(com.google.appengine.api.datastore.Entity fromEntity, T toPojo)
fromEntity
- is a raw datastore entitytoPojo
- is your typed entitypublic void loadSingleValue(java.lang.String key, java.lang.Object value, java.lang.Object toPojo, LoadContext context)
value
into toPojo
using key
as the key within
the entity. Will use any of rootSetters
or might delegate through a map setter.
key
- the key for this valuevalue
- the value from the datastoretoPojo
- the target pojo to load intopublic void save(T fromPojo, com.google.appengine.api.datastore.Entity toEntity)
fromPojo
- is your typed entitytoEntity
- is a raw datastore entity
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |