Class KeyMetadata<P>

java.lang.Object
com.googlecode.objectify.impl.KeyMetadata<P>

public class KeyMetadata<P> extends Object
Figures out what to do with key fields on POJO entities.
Author:
Jeff Schnitzer invalid input: '<'[email protected]>
  • Constructor Details

  • Method Details

    • setKey

      public void setKey(P pojo, com.google.cloud.datastore.FullEntity<?> container, LoadContext ctx, Path containerPath)
      Sets the key (from the container) onto the POJO id/parent fields. Also doublechecks to make sure that the key fields aren't present in the container, which means we're in a very bad state.
    • setKey

      public <K extends com.google.cloud.datastore.IncompleteKey> void setKey(com.google.cloud.datastore.FullEntity.Builder<K> container, P pojo)
      Sets the key on a container from the POJO.
    • getKind

      public String getKind()
      Returns:
      the datastore kind associated with this metadata
    • getIncompleteKey

      public com.google.cloud.datastore.IncompleteKey getIncompleteKey(P pojo, String namespaceHint)
      Gets a key composed of the relevant id and parent fields in the object.
      Parameters:
      pojo - must be of the entityClass type for this metadata.
      namespaceHint - is a namespace that will be used if one is not specified in the pojo
      Returns:
      either a Key or IncompleteKey depending on whether the id is null or not
    • getCompleteKey

      public com.google.cloud.datastore.Key getCompleteKey(P pojo, String namespaceHint)
      Gets a key composed of the relevant id and parent fields in the object.
      Parameters:
      pojo - must be of the entityClass type for this metadata.
      Throws:
      IllegalArgumentException - if pojo has an incomplete key
    • getParentFieldName

      public String getParentFieldName()
      Returns:
      the name of the parent field, or null if there wasn't one
    • getIdFieldName

      public String getIdFieldName()
      Returns:
      the name of the id field
    • getIdFieldType

      public Class<?> getIdFieldType()
      Returns:
      the java type of the id field; it will be either Long.class, Long.TYPE, or String.class
    • hasParentField

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

      public boolean shouldLoadParent(Set<Class<?>> enabledGroups)
      Returns:
      true if the parent should be loaded given the enabled fetch groups
    • isIdGeneratable

      public boolean isIdGeneratable()
      Returns:
      true if the id field is uppercase-Long, which can be genearted.
    • setLongId

      public void setLongId(P pojo, Long id)
      Sets the numeric id field
    • requiresAutogeneratedId

      public boolean requiresAutogeneratedId(P entity)
      Change this slightly to just a null check on the id so that null String will be allowed. The advantage of this is that we'll get a consistent error message when you actually try to save a null String id, instead of the weird things that will happen when you try to generate a Key for the object.
      Returns:
      true if this entity object has a null id