Class ProfileDB


  • public class ProfileDB
    extends java.lang.Object
    This class provides facilities to save and load Experiments.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProfileDB​(Storage storage)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void append​(java.util.Collection<Experiment> experiments)
      Related to file based storage, Receive a Collection of Experiments and persist them at the end of a file
      void append​(Experiment... experiments)
      Related to file based storage, Receive an array of Experiments and persist them at the end of a file
      com.google.gson.Gson getGson()
      Provide a Gson object.
      Storage getStorage()
      To work with storage object provided to persist or load experiments
      java.util.Collection<Experiment> load()
      Bring Experiments from current Storage to local variable
      java.util.Collection<Experiment> load​(java.io.InputStream inputStream)
      Bring Experiments from current Storage to local variable
      ProfileDB registerMeasurementClass​(java.lang.Class<? extends Measurement> measurementClass)
      Register a Measurement type.
      void save​(java.util.Collection<Experiment> experiments)
      Receive a Collection of Experiments and persist them
      void save​(java.util.Collection<Experiment> experiments, java.io.OutputStream outputStream)
      Receive a Collection of Experiments and persist them
      void save​(Experiment... experiments)
      Receive an array of Experiments and persist them
      ProfileDB withGsonPreparation​(java.util.function.Consumer<com.google.gson.GsonBuilder> preparation)
      Apply any changes necessary to Gson so that it can be used for de/serialization of custom objects.
      • Methods inherited from class java.lang.Object

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

      • ProfileDB

        public ProfileDB​(Storage storage)
        Creates a new instance.
    • Method Detail

      • save

        public void save​(Experiment... experiments)
                  throws java.io.IOException
        Receive an array of Experiments and persist them
        Parameters:
        experiments - Array of Experiments to be persisted
        Throws:
        java.io.IOException
      • save

        public void save​(java.util.Collection<Experiment> experiments)
                  throws java.io.IOException
        Receive a Collection of Experiments and persist them
        Parameters:
        experiments - Collection of Experiments to be persisted
        Throws:
        java.io.IOException
      • save

        public void save​(java.util.Collection<Experiment> experiments,
                         java.io.OutputStream outputStream)
                  throws java.io.IOException
        Receive a Collection of Experiments and persist them
        Parameters:
        experiments - Collection of Experiments to be persisted
        outputStream - Indicates where the data must to be written
        Throws:
        java.io.IOException
      • append

        public void append​(Experiment... experiments)
                    throws java.io.IOException
        Related to file based storage, Receive an array of Experiments and persist them at the end of a file
        Parameters:
        experiments - Array of Experiments to be persisted
        Throws:
        java.io.IOException
      • append

        public void append​(java.util.Collection<Experiment> experiments)
                    throws java.io.IOException
        Related to file based storage, Receive a Collection of Experiments and persist them at the end of a file
        Parameters:
        experiments - Collection of Experiments to be persisted
        Throws:
        java.io.IOException
      • load

        public java.util.Collection<Experiment> load()
                                              throws java.io.IOException
        Bring Experiments from current Storage to local variable
        Returns:
        Collection of Experiments
        Throws:
        java.io.IOException
      • load

        public java.util.Collection<Experiment> load​(java.io.InputStream inputStream)
                                              throws java.io.IOException
        Bring Experiments from current Storage to local variable
        Parameters:
        inputStream - Data to be read
        Returns:
        Collection of Experiments
        Throws:
        java.io.IOException
      • getStorage

        public Storage getStorage()
        To work with storage object provided to persist or load experiments
        Returns:
        Storage object proportioned for this instance
      • registerMeasurementClass

        public ProfileDB registerMeasurementClass​(java.lang.Class<? extends Measurement> measurementClass)
        Register a Measurement type. This is required before being able to load that type.
        Parameters:
        measurementClass - the Measurement Class
        Returns:
        this instance
      • withGsonPreparation

        public ProfileDB withGsonPreparation​(java.util.function.Consumer<com.google.gson.GsonBuilder> preparation)
        Apply any changes necessary to Gson so that it can be used for de/serialization of custom objects.
        Parameters:
        preparation - a preparatory step performed on a GsonBuilder
        Returns:
        this instance
      • getGson

        public com.google.gson.Gson getGson()
        Provide a Gson object.
        Returns:
        the Gson object