Class ProfileDB
- java.lang.Object
-
- org.apache.wayang.commons.util.profiledb.ProfileDB
-
public class ProfileDB extends java.lang.Object
This class provides facilities to save and loadExperiment
s.
-
-
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 ofExperiment
s and persist them at the end of a filevoid
append(Experiment... experiments)
Related to file based storage, Receive an array ofExperiment
s and persist them at the end of a filecom.google.gson.Gson
getGson()
Provide aGson
object.Storage
getStorage()
To work with storage object provided to persist or load experimentsjava.util.Collection<Experiment>
load()
BringExperiment
s from current Storage to local variablejava.util.Collection<Experiment>
load(java.io.InputStream inputStream)
BringExperiment
s from current Storage to local variableProfileDB
registerMeasurementClass(java.lang.Class<? extends Measurement> measurementClass)
Register aMeasurement
type.void
save(java.util.Collection<Experiment> experiments)
Receive a Collection ofExperiment
s and persist themvoid
save(java.util.Collection<Experiment> experiments, java.io.OutputStream outputStream)
Receive a Collection ofExperiment
s and persist themvoid
save(Experiment... experiments)
Receive an array ofExperiment
s and persist themProfileDB
withGsonPreparation(java.util.function.Consumer<com.google.gson.GsonBuilder> preparation)
Apply any changes necessary toGson
so 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 ofExperiment
s and persist them- Parameters:
experiments
- Array ofExperiment
s to be persisted- Throws:
java.io.IOException
-
save
public void save(java.util.Collection<Experiment> experiments) throws java.io.IOException
Receive a Collection ofExperiment
s and persist them- Parameters:
experiments
- Collection ofExperiment
s 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 ofExperiment
s and persist them- Parameters:
experiments
- Collection ofExperiment
s 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 ofExperiment
s and persist them at the end of a file- Parameters:
experiments
- Array ofExperiment
s 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 ofExperiment
s and persist them at the end of a file- Parameters:
experiments
- Collection ofExperiment
s to be persisted- Throws:
java.io.IOException
-
load
public java.util.Collection<Experiment> load() throws java.io.IOException
BringExperiment
s from current Storage to local variable- Returns:
- Collection of
Experiment
s - Throws:
java.io.IOException
-
load
public java.util.Collection<Experiment> load(java.io.InputStream inputStream) throws java.io.IOException
BringExperiment
s from current Storage to local variable- Parameters:
inputStream
- Data to be read- Returns:
- Collection of
Experiment
s - 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 aMeasurement
type. This is required before being able to load that type.- Parameters:
measurementClass
- theMeasurement
Class
- Returns:
- this instance
-
withGsonPreparation
public ProfileDB withGsonPreparation(java.util.function.Consumer<com.google.gson.GsonBuilder> preparation)
Apply any changes necessary toGson
so 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 aGson
object.- Returns:
- the
Gson
object
-
-