Class TranslatorRecycles<P,​D>

  • All Implemented Interfaces:
    Recycles, Translator<P,​D>

    public abstract class TranslatorRecycles<P,​D>
    extends Object
    implements Translator<P,​D>, Recycles
    Combines Translator with Recycles, useful so that we can create anonymous classes. Skips if the loaded value is the same as into; this means we won't need to modify potentially final fields.
    Author:
    Jeff Schnitzer
    • Constructor Detail

      • TranslatorRecycles

        public TranslatorRecycles()
    • Method Detail

      • load

        public final P load​(com.google.cloud.datastore.Value<D> node,
                            LoadContext ctx,
                            Path path)
                     throws SkipException
        Description copied from interface: Translator

        Loads the content of the specified datastore node, returning the pojo equivalent.

        There is one special return value: If a Result is returned, the content of the Result will be used instead, but delayed until ctx.done() is called. This happens at the end of a "round" of load operations and is the magic trick that makes populating entity references work efficiently.

        Specified by:
        load in interface Translator<P,​D>
        Parameters:
        node - is the part of the native datastore entity tree we are transforming.
        ctx - holds state information during an entity load.
        path - is the current path to this translator
        Returns:
        an assembled pojo corresponding to the node subtree; if null is returned, that is the real value!
        Throws:
        SkipException - if the return value should be abandoned.
        See Also:
        LoadEngine
      • loadInto

        protected abstract P loadInto​(com.google.cloud.datastore.Value<D> node,
                                      LoadContext ctx,
                                      Path path,
                                      P into)