Class DataUpdateTransaction
- java.lang.Object
-
- org.openmuc.jeebus.spine.spi.function.DataUpdateTransaction
-
public class DataUpdateTransaction extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDataUpdateTransaction.AfterUpdateListCallstatic interfaceDataUpdateTransaction.AfterUpdateSingleCallstatic classDataUpdateTransaction.UpdateType
-
Constructor Summary
Constructors Constructor Description DataUpdateTransaction()Create an instance of this class to add data for multiple feature functions with validation happening for the state after all data is added.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <DATA> voidaddDataList(ReadListFeatureFunction<DATA,?,?,?,?> featureFunction, java.util.List<DATA> dataList, DataUpdateTransaction.AfterUpdateListCall afterUpdateListCall)Add a list of data objects that should be added to the feature function for this transaction.<DATA> voidaddSingleData(ReadListFeatureFunction<DATA,?,?,?,?> featureFunction, DATA data, DataUpdateTransaction.AfterUpdateSingleCall afterUpdateListCall)Add a single data object to the given function for this transaction.<DATA> voidaddSingleData(ReadSingleFeatureFunction<DATA,?,?> featureFunction, DATA update)voidrunUpdate()Runs the update by adding the new data, validating it and notifying the subscribers.
-
-
-
Constructor Detail
-
DataUpdateTransaction
public DataUpdateTransaction()
Create an instance of this class to add data for multiple feature functions with validation happening for the state after all data is added. Runs update only after whenrunUpdate()is called. Notifies subscribers for each update.
-
-
Method Detail
-
addSingleData
public <DATA> void addSingleData(ReadListFeatureFunction<DATA,?,?,?,?> featureFunction, DATA data, DataUpdateTransaction.AfterUpdateSingleCall afterUpdateListCall)
Add a single data object to the given function for this transaction. Each call of this method notifies the subscribers separately for the added data whenrunUpdate()is called.- Type Parameters:
DATA- the data type of the feature function- Parameters:
featureFunction- the feature function to add the data todata- the data to addafterUpdateListCall- method that is called with the index where the data was added to in the feature function whenrunUpdate()is called
-
addSingleData
public <DATA> void addSingleData(ReadSingleFeatureFunction<DATA,?,?> featureFunction, DATA update)
-
addDataList
public <DATA> void addDataList(ReadListFeatureFunction<DATA,?,?,?,?> featureFunction, java.util.List<DATA> dataList, DataUpdateTransaction.AfterUpdateListCall afterUpdateListCall)
Add a list of data objects that should be added to the feature function for this transaction. Notifies subscribers once for the added data whenrunUpdate()is called.- Type Parameters:
DATA- the data type of the feature function- Parameters:
featureFunction- the feature function to add the data todataList- the data to addafterUpdateListCall- method that is called with a list of indices where the data was added to in the feature function whenrunUpdate()is called (in order of the given data list)
-
runUpdate
public void runUpdate() throws DataValidationExceptionRuns the update by adding the new data, validating it and notifying the subscribers. If validation fails the whole transaction will terminate without any data changed.- Throws:
DataValidationException- if the validation fails
-
-