Class PropertyPopulator<P,​D>

  • All Implemented Interfaces:
    Populator<P>

    public class PropertyPopulator<P,​D>
    extends Object
    implements Populator<P>
    Associates a Property with a Translator and provides a more convenient interface.
    • Constructor Detail

      • PropertyPopulator

        public PropertyPopulator()
    • Method Detail

      • toString

        public String toString()
        This is easier to debug if we have a string value
        Overrides:
        toString in class Object
      • load

        public void load​(com.google.cloud.datastore.FullEntity<?> container,
                         LoadContext ctx,
                         Path containerPath,
                         P intoPojo)
        Gets the appropriate value from the container and sets it on the appropriate field of the pojo.
        Specified by:
        load in interface Populator<P>
        Parameters:
        container - is the part of the native datastore entity tree we are transforming.
        ctx - holds state information during an entity load.
        containerPath - is the current path to this POJO
      • setValue

        public void setValue​(Object pojo,
                             com.google.cloud.datastore.Value<D> value,
                             LoadContext ctx,
                             Path containerPath)
                      throws SkipException
        Set this raw datastore value on the relevant property of the pojo, doing whatever translations are necessary.
        Throws:
        SkipException
      • save

        public void save​(P onPojo,
                         boolean index,
                         SaveContext ctx,
                         Path containerPath,
                         com.google.cloud.datastore.FullEntity.Builder<?> into)
        Gets the appropriate field value from the pojo and puts it in the container at the appropriate prop name and with the appropriate indexing.
        Specified by:
        save in interface Populator<P>
        Parameters:
        onPojo - is the parent pojo which holds the property we represent
        index - is the default state of indexing up to this point
        containerPath - is the path to the container; each property will extend this path.
      • getValue

        public com.google.cloud.datastore.Value<D> getValue​(Object pojo,
                                                            SaveContext ctx,
                                                            Path containerPath)
        Get the value for the property and translate it into datastore format.