Class DatastoreUtils

java.lang.Object
com.googlecode.objectify.util.DatastoreUtils

public class DatastoreUtils
extends Object
Some static utility methods for interacting with basic datastore objects like keys and queries.
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.google.appengine.api.datastore.Query
    cloneQuery​(com.google.appengine.api.datastore.Query orig)
    Make a new Query object that is exactly like the old.
    static com.google.appengine.api.datastore.Key
    createKey​(com.google.appengine.api.datastore.Key parent, String kind, Object id)
    Construct a Key from a Long or String id
    static <T> Key<T>
    createKey​(Key<?> parent, Class<T> kind, Object id)
    Construct a Key from a Long or String id
    static <T> Key<T>
    createKey​(Key<?> parent, String kind, Object id)
    Construct a Key from a Long or String id
    static List<com.google.appengine.api.datastore.Key>
    createKeys​(com.google.appengine.api.datastore.Key parent, String kind, Iterable<?> ids)
    Make a list of keys
    static <T> List<Key<T>>
    createKeys​(Key<?> parent, Class<T> kind, Iterable<?> ids)
    Make a list of Keys
    static <S> S
    getId​(com.google.appengine.api.datastore.Key key)
    Gets the String or Long id from the key, or null if incomplete
    static <S> S
    getId​(Key<?> key)
    Gets the String or Long id from the key, or null if incomplete
    static com.google.appengine.api.datastore.Key
    getKey​(com.google.appengine.api.datastore.PropertyContainer container)
    Unfortunately Entity and EmbeddedEntity do not share a common interface for getting key.
    static List<com.google.appengine.api.datastore.Key>
    getRawKeys​(Iterable<? extends Ref<?>> refs)
    Turn a list of refs into a list of raw keys.
    static void
    setContainerProperty​(com.google.appengine.api.datastore.PropertyContainer entity, String propertyName, Object value, boolean index, SaveContext ctx, Path propPath)
    Calls setProperty() or setUnindexedProperty() as determined by the index parameter.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getRawKeys

      public static List<com.google.appengine.api.datastore.Key> getRawKeys(Iterable<? extends Ref<?>> refs)
      Turn a list of refs into a list of raw keys.
    • cloneQuery

      public static com.google.appengine.api.datastore.Query cloneQuery(com.google.appengine.api.datastore.Query orig)
      Make a new Query object that is exactly like the old. Too bad Query isn't Cloneable.
    • createKey

      public static <T> Key<T> createKey(Key<?> parent, Class<T> kind, Object id)
      Construct a Key from a Long or String id
      Parameters:
      id - must be either Long or String
    • createKey

      public static <T> Key<T> createKey(Key<?> parent, String kind, Object id)
      Construct a Key from a Long or String id
      Parameters:
      id - must be either Long or String
    • createKey

      public static com.google.appengine.api.datastore.Key createKey(com.google.appengine.api.datastore.Key parent, String kind, Object id)
      Construct a Key from a Long or String id
      Parameters:
      id - must be either Long or String
    • createKeys

      public static List<com.google.appengine.api.datastore.Key> createKeys(com.google.appengine.api.datastore.Key parent, String kind, Iterable<?> ids)
      Make a list of keys
      Parameters:
      ids - must contain either Long or String
    • createKeys

      public static <T> List<Key<T>> createKeys(Key<?> parent, Class<T> kind, Iterable<?> ids)
      Make a list of Keys
      Parameters:
      ids - must contain either Long or String
    • getId

      public static <S> S getId(com.google.appengine.api.datastore.Key key)
      Gets the String or Long id from the key, or null if incomplete
    • getId

      public static <S> S getId(Key<?> key)
      Gets the String or Long id from the key, or null if incomplete
    • getKey

      public static com.google.appengine.api.datastore.Key getKey(com.google.appengine.api.datastore.PropertyContainer container)
      Unfortunately Entity and EmbeddedEntity do not share a common interface for getting key.
    • setContainerProperty

      public static void setContainerProperty(com.google.appengine.api.datastore.PropertyContainer entity, String propertyName, Object value, boolean index, SaveContext ctx, Path propPath)
      Calls setProperty() or setUnindexedProperty() as determined by the index parameter. Also stuffs any values in the savecontext index.