Class ValueTranslator<P,D>

java.lang.Object
com.googlecode.objectify.impl.translate.NullSafeTranslator<P,D>
com.googlecode.objectify.impl.translate.ValueTranslator<P,D>
All Implemented Interfaces:
Translator<P,D>

public abstract class ValueTranslator<P,D> extends NullSafeTranslator<P,D>

Translator that should be extended for typical atomic values. Does a little bit of expected type checking and handles indexing for us.

Author:
Jeff Schnitzer invalid input: '<'[email protected]>
  • Constructor Summary

    Constructors
    Constructor
    Description
    ValueTranslator(com.google.cloud.datastore.ValueType... expectedValueTypes)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final P
    loadSafe(com.google.cloud.datastore.Value<D> value, LoadContext ctx, Path path)
    Implement this, returning a proper translated value
    protected abstract P
    loadValue(com.google.cloud.datastore.Value<D> value, LoadContext ctx, Path path)
    Decode from a property value as stored in the datastore to a type that will be stored in a pojo.
    protected final com.google.cloud.datastore.Value<D>
    saveSafe(P pojo, boolean index, SaveContext ctx, Path path)
    Implement this, returning a proper translated value
    protected abstract com.google.cloud.datastore.Value<D>
    saveValue(P value, SaveContext ctx, Path path)
    Encode from a normal pojo value to a format that the datastore understands.

    Methods inherited from class com.googlecode.objectify.impl.translate.NullSafeTranslator

    load, save

    Methods inherited from class java.lang.Object

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

    • ValueTranslator

      public ValueTranslator(com.google.cloud.datastore.ValueType... expectedValueTypes)
  • Method Details

    • loadSafe

      protected final P loadSafe(com.google.cloud.datastore.Value<D> value, LoadContext ctx, Path path) throws SkipException
      Description copied from class: NullSafeTranslator
      Implement this, returning a proper translated value
      Specified by:
      loadSafe in class NullSafeTranslator<P,D>
      Parameters:
      value - will never be null or NullValue
      Throws:
      SkipException
    • saveSafe

      protected final com.google.cloud.datastore.Value<D> saveSafe(P pojo, boolean index, SaveContext ctx, Path path) throws SkipException
      Description copied from class: NullSafeTranslator
      Implement this, returning a proper translated value
      Specified by:
      saveSafe in class NullSafeTranslator<P,D>
      Parameters:
      pojo - will never be null
      Throws:
      SkipException
    • loadValue

      protected abstract P loadValue(com.google.cloud.datastore.Value<D> value, LoadContext ctx, Path path) throws SkipException
      Decode from a property value as stored in the datastore to a type that will be stored in a pojo.
      Parameters:
      value - will not be null and will actually be the correct type
      Returns:
      the format which should be stored in the pojo; a null means store a literal null!
      Throws:
      SkipException - if this field subtree should be skipped
    • saveValue

      protected abstract com.google.cloud.datastore.Value<D> saveValue(P value, SaveContext ctx, Path path) throws SkipException
      Encode from a normal pojo value to a format that the datastore understands. Note that a null return value is a literal instruction to store a null.
      Parameters:
      value - will not be null
      Returns:
      the format which should be stored in the datastore; null means actually store a null!
      Throws:
      SkipException - if this subtree should be skipped