Navigation Menu

Skip to content

Commit

Permalink
turned get methods in EntityTransformationHelper to be compiled static
Browse files Browse the repository at this point in the history
  • Loading branch information
musketyr committed Mar 24, 2014
1 parent feca706 commit dcab00d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
Expand Up @@ -9,6 +9,23 @@

public class DatastoreEntityCoercion {

public static enum Proxy {
INSTANCE;

Entity convert(DatastoreEntity dsEntity){
return DatastoreEntityCoercion.convert(dsEntity);
}

public static Object convert(Entity en, Class dsEntityClass, DatastoreEntity dsEntity) throws InstantiationException, IllegalAccessException{
return DatastoreEntityCoercion.convert(en, dsEntityClass, dsEntity);
}

public static Object convert(Entity en, Class dsEntityClass) throws InstantiationException, IllegalAccessException{
return DatastoreEntityCoercion.convert(en, dsEntityClass);
}

}

public static Entity convert(DatastoreEntity<?> dsEntity){
if(dsEntity == null) return null;

Expand Down
Expand Up @@ -49,37 +49,37 @@ class EntityTransformationHelper {
DatastoreExtensions.delete((Entity)DatastoreExtensions.asType(pogo, Entity))
}

@CompileStatic(TypeCheckingMode.SKIP)
static <P> P get(Class<P> pogoClass, long key) {
static <P extends DatastoreEntity<?>> P get(Class<P> pogoClass, long key) {
try {
return DatastoreExtensions.asType(DatastoreExtensions.get(KeyFactory.createKey(pogoClass.simpleName, key)), pogoClass)
Entity entity = DatastoreExtensions.get(KeyFactory.createKey(pogoClass.simpleName, key))
return (P) DatastoreEntityCoercion.Proxy.INSTANCE.convert(entity, pogoClass)
} catch (EntityNotFoundException e) {
return null
}
}

@CompileStatic(TypeCheckingMode.SKIP)
static <P> P get(Class<P> pogoClass, String key) {
static <P extends DatastoreEntity<?>> P get(Class<P> pogoClass, String key) {
try {
return DatastoreExtensions.asType(DatastoreExtensions.get(KeyFactory.createKey(pogoClass.simpleName, key)), pogoClass)
Entity entity = DatastoreExtensions.get(KeyFactory.createKey(pogoClass.simpleName, key))
return (P) DatastoreEntityCoercion.Proxy.INSTANCE.convert(entity, pogoClass)
} catch (EntityNotFoundException e) {
return null
}
}

@CompileStatic(TypeCheckingMode.SKIP)
static <P> P get(Class<P> pogoClass, Key parentKey, long key) {
static <P extends DatastoreEntity<?>> P get(Class<P> pogoClass, Key parentKey, long key) {
try {
return DatastoreExtensions.asType(DatastoreExtensions.get(KeyFactory.createKey(parentKey, pogoClass.simpleName, key)), pogoClass)
Entity entity = DatastoreExtensions.get(KeyFactory.createKey(parentKey, pogoClass.simpleName, key))
return (P) DatastoreEntityCoercion.Proxy.INSTANCE.convert(entity, pogoClass)
} catch (EntityNotFoundException e) {
return null
}
}

@CompileStatic(TypeCheckingMode.SKIP)
static <P> P get(Class<P> pogoClass, Key parentKey, String key) {
static <P extends DatastoreEntity<?>> P get(Class<P> pogoClass, Key parentKey, String key) {
try {
return DatastoreExtensions.asType(DatastoreExtensions.get(KeyFactory.createKey(parentKey, pogoClass.simpleName, key)), pogoClass)
Entity entity = DatastoreExtensions.get(KeyFactory.createKey(parentKey, pogoClass.simpleName, key))
return (P) DatastoreEntityCoercion.Proxy.INSTANCE.convert(entity, pogoClass)
} catch (EntityNotFoundException e) {
return null
}
Expand Down

0 comments on commit dcab00d

Please sign in to comment.