Class ProfileDB
- java.lang.Object
-
- org.apache.wayang.commons.util.profiledb.ProfileDB
-
public class ProfileDB extends java.lang.ObjectThis class provides facilities to save and loadExperiments.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(java.util.Collection<Experiment> experiments)Related to file based storage, Receive a Collection ofExperiments and persist them at the end of a filevoidappend(Experiment... experiments)Related to file based storage, Receive an array ofExperiments and persist them at the end of a filecom.google.gson.GsongetGson()Provide aGsonobject.StoragegetStorage()To work with storage object provided to persist or load experimentsjava.util.Collection<Experiment>load()BringExperiments from current Storage to local variablejava.util.Collection<Experiment>load(java.io.InputStream inputStream)BringExperiments from current Storage to local variableProfileDBregisterMeasurementClass(java.lang.Class<? extends Measurement> measurementClass)Register aMeasurementtype.voidsave(java.util.Collection<Experiment> experiments)Receive a Collection ofExperiments and persist themvoidsave(java.util.Collection<Experiment> experiments, java.io.OutputStream outputStream)Receive a Collection ofExperiments and persist themvoidsave(Experiment... experiments)Receive an array ofExperiments and persist themProfileDBwithGsonPreparation(java.util.function.Consumer<com.google.gson.GsonBuilder> preparation)Apply any changes necessary toGsonso that it can be used for de/serialization of custom objects.
-
-
-
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 ofExperiments and persist them- Parameters:
experiments- Array ofExperiments to be persisted- Throws:
java.io.IOException
-
save
public void save(java.util.Collection<Experiment> experiments) throws java.io.IOException
Receive a Collection ofExperiments and persist them- Parameters:
experiments- Collection ofExperiments 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 ofExperiments and persist them- Parameters:
experiments- Collection ofExperiments to be persistedoutputStream- 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 ofExperiments and persist them at the end of a file- Parameters:
experiments- Array ofExperiments 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 ofExperiments and persist them at the end of a file- Parameters:
experiments- Collection ofExperiments to be persisted- Throws:
java.io.IOException
-
load
public java.util.Collection<Experiment> load() throws java.io.IOException
BringExperiments 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
BringExperiments 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 aMeasurementtype. This is required before being able to load that type.- Parameters:
measurementClass- theMeasurementClass- Returns:
- this instance
-
withGsonPreparation
public ProfileDB withGsonPreparation(java.util.function.Consumer<com.google.gson.GsonBuilder> preparation)
Apply any changes necessary toGsonso that it can be used for de/serialization of custom objects.- Parameters:
preparation- a preparatory step performed on aGsonBuilder- Returns:
- this instance
-
getGson
public com.google.gson.Gson getGson()
Provide aGsonobject.- Returns:
- the
Gsonobject
-
-