Class ReadAndWriteListFeatureFunction<DATA,DATA_LIST,SELECTOR,ELEMENTS,TYPE extends ListFeatureFunctionTypeInfo<DATA,DATA_LIST,SELECTOR,ELEMENTS>>
- java.lang.Object
-
- org.openmuc.jeebus.spine.spi.function.FeatureFunction
-
- org.openmuc.jeebus.spine.spi.function.ReadListFeatureFunction<DATA,DATA_LIST,SELECTOR,ELEMENTS,TYPE>
-
- org.openmuc.jeebus.spine.spi.function.ReadAndWriteListFeatureFunction<DATA,DATA_LIST,SELECTOR,ELEMENTS,TYPE>
-
- All Implemented Interfaces:
java.lang.AutoCloseable,Shutdownable
- Direct Known Subclasses:
CharacteristicListDataFunction,DescriptionListDataFunction,KeyValueConstraintsListDataFunction,KeyValueDescriptionListDataFunction,KeyValueListDataFunction,LoadControlFeatureFunction,ParameterDescriptionListDataFunction,PermittedValueSetListDataFunction,StateListDataFunction
public abstract class ReadAndWriteListFeatureFunction<DATA,DATA_LIST,SELECTOR,ELEMENTS,TYPE extends ListFeatureFunctionTypeInfo<DATA,DATA_LIST,SELECTOR,ELEMENTS>> extends ReadListFeatureFunction<DATA,DATA_LIST,SELECTOR,ELEMENTS,TYPE>
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Loggerloggerprotected WriteDataListListener<DATA>useCaseWriteDataListListener-
Fields inherited from class org.openmuc.jeebus.spine.spi.function.ReadListFeatureFunction
allowedReadListCmdOptions, dataListHolder, listFeatureFunctionNotifier
-
Fields inherited from class org.openmuc.jeebus.spine.spi.function.FeatureFunction
feature
-
-
Constructor Summary
Constructors Constructor Description ReadAndWriteListFeatureFunction(java.lang.String functionName, TYPE typeInfo)Constructs a ReadAndWriteFeatureFunction.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voiddeleteDataEntriesBySelector(java.util.List<SELECTOR> selectorList)Deletes data entries for selectors and notifies subscribers that data entries were deleted.java.util.Set<WriteListCmdOption>getAllowedWriteCmdOptions()TYPEgetTypeInfo()DataValidation<DATA>getUseCaseDataValidation()voidsetAllowedWriteCmdOptions(WriteListCmdOption... allowedCmdWriteOptions)Sets the allowedWriteListCmdOptions defined by the FeatureFunction/Use Case.voidsetUseCaseDataValidation(DataValidation<DATA> useCaseDataValidation)voidsetUseCaseMatchingDataWriteValidation(MatchingDataWriteListValidation<DATA> useCaseMatchingDataWriteListValidation)Validates the read command likevalidateUpdateForMatchingData(DATA, java.util.List<DATA>, org.openmuc.jeebus.spine.api.options.WriteListCmdOption).voidsetUseCaseWriteDataListener(WriteDataListListener<DATA> useCaseWriteDataListListener)Sets a listener that is called when changes were made to any data.voidsetUseCaseWriteValidationFull(WriteListValidationFull<DATA,SELECTOR,ELEMENTS> writeValidationFull)Validates the write command likevalidateWriteCmd(org.openmuc.jeebus.spine.xsd.v1.FilterType, org.openmuc.jeebus.spine.xsd.v1.FilterType, java.util.List<DATA>).protected abstract voidvalidateData(DATA data)Validates the given data.protected abstract voidvalidateUpdateForMatchingData(DATA update, java.util.List<DATA> matchingData, WriteListCmdOption writeListCmdOption)Validates each update data for its matching data that is changed by the update data.protected abstract voidvalidateWriteCmdFull(java.util.List<DATA> updateList, java.util.List<SELECTOR> selectorList, ELEMENTS elements, WriteListCmdOption writeListCmdOption)Validates a write command by taking the full update data list, selector list, elementsType object and theWriteListCmdOptionthat is used.SpineAcknowledgmentwrite(org.openmuc.jeebus.spine.xsd.v1.CmdType cmd, org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType sourceAddress)abstract voidwriteData(DATA data, DataUpdateType dataUpdateType, java.lang.Integer idx)Called when changes were made to any data.-
Methods inherited from class org.openmuc.jeebus.spine.spi.function.ReadListFeatureFunction
addData, addData, close, getAllowedReadCmdOptions, getDataCopies, getDataCopiesFor, getDataCopy, getDataCopyForFirst, read, removeData, removeData, setAllowedReadCmdOptions, setFeature, setUseCaseReadValidation, updateData, updateData, validateReadCmd
-
Methods inherited from class org.openmuc.jeebus.spine.spi.function.FeatureFunction
bindingRequired, call, getFunctionName, getFunctionProperty, isCallable, isReadable, isWritable, matchAddress, requireBinding, setCallable, setReadable, setWritable
-
-
-
-
Field Detail
-
useCaseWriteDataListListener
protected WriteDataListListener<DATA> useCaseWriteDataListListener
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Detail
-
ReadAndWriteListFeatureFunction
public ReadAndWriteListFeatureFunction(java.lang.String functionName, TYPE typeInfo)Constructs a ReadAndWriteFeatureFunction. If FeatureFunction shall be none identifiable use an emptyDataIdDescriptionby usingDataIdDescription.getNoneIdentifiableDataDescription(Class). This class automatically executes read and write commands for the given Feature Function. Additional validation of commands is done by abstract validation methods and validation functions that may be set by the Use Case Implementation.- Parameters:
functionName- the name of the functiontypeInfo- the RTTI object for this feature function
-
-
Method Detail
-
setUseCaseMatchingDataWriteValidation
public void setUseCaseMatchingDataWriteValidation(MatchingDataWriteListValidation<DATA> useCaseMatchingDataWriteListValidation)
Validates the read command likevalidateUpdateForMatchingData(DATA, java.util.List<DATA>, org.openmuc.jeebus.spine.api.options.WriteListCmdOption). Should be set by the Use Case Implementation.- Parameters:
useCaseMatchingDataWriteListValidation- theMatchingDataWriteListValidationfunctional interface function
-
setUseCaseWriteValidationFull
public void setUseCaseWriteValidationFull(WriteListValidationFull<DATA,SELECTOR,ELEMENTS> writeValidationFull)
Validates the write command likevalidateWriteCmd(org.openmuc.jeebus.spine.xsd.v1.FilterType, org.openmuc.jeebus.spine.xsd.v1.FilterType, java.util.List<DATA>). Should be set by the Use Case Implementation.- Parameters:
writeValidationFull- theWriteListValidationFullfunction interface function
-
setUseCaseWriteDataListener
public void setUseCaseWriteDataListener(WriteDataListListener<DATA> useCaseWriteDataListListener)
Sets a listener that is called when changes were made to any data.- Parameters:
useCaseWriteDataListListener- the listener
-
getAllowedWriteCmdOptions
public java.util.Set<WriteListCmdOption> getAllowedWriteCmdOptions()
-
setAllowedWriteCmdOptions
public void setAllowedWriteCmdOptions(WriteListCmdOption... allowedCmdWriteOptions)
Sets the allowedWriteListCmdOptions defined by the FeatureFunction/Use Case.- Parameters:
allowedCmdWriteOptions- the allowedWriteListCmdOptions
-
writeData
public abstract void writeData(DATA data, DataUpdateType dataUpdateType, java.lang.Integer idx)
Called when changes were made to any data.- Parameters:
data- the data that was updated (copy of the original data), fully deleted or newly addeddataUpdateType- if the data shall be updated, deleted or newly addedidx- index where at the data was added for this feature function
-
validateUpdateForMatchingData
protected abstract void validateUpdateForMatchingData(DATA update, java.util.List<DATA> matchingData, WriteListCmdOption writeListCmdOption) throws SpineException
Validates each update data for its matching data that is changed by the update data. This is called for each update data on partial or full write. Must be implemented by the specific Feature Function.- Parameters:
update- the given updatematchingData- the data that is to be changed by the updatewriteListCmdOption- theWriteListCmdOptionthat is used- Throws:
SpineException- if the validation fails
-
validateWriteCmdFull
protected abstract void validateWriteCmdFull(java.util.List<DATA> updateList, java.util.List<SELECTOR> selectorList, ELEMENTS elements, WriteListCmdOption writeListCmdOption) throws SpineException
Validates a write command by taking the full update data list, selector list, elementsType object and theWriteListCmdOptionthat is used. This may be called twice for one command if both Delete and Write are used. Must be implemented by the specific Feature Function.- Parameters:
updateList- the full update data list (can be null on DELETE writeCmdOption)selectorList- the full selector list of the command, may be emptyelements- the elementsType object, may be nullwriteListCmdOption- theWriteListCmdOptionthat is used- Throws:
SpineException- if the validation fails
-
write
public SpineAcknowledgment write(org.openmuc.jeebus.spine.xsd.v1.CmdType cmd, org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType sourceAddress) throws SpineException
- Overrides:
writein classReadListFeatureFunction<DATA,DATA_LIST,SELECTOR,ELEMENTS,TYPE extends ListFeatureFunctionTypeInfo<DATA,DATA_LIST,SELECTOR,ELEMENTS>>- Parameters:
cmd- to be written data including optional filters for restricted function exchangesourceAddress- the feature address of the client feature- Returns:
- an acknowledgment stating the result of the operation
- Throws:
SpineException- if the write command encounters an exception
-
deleteDataEntriesBySelector
public void deleteDataEntriesBySelector(java.util.List<SELECTOR> selectorList) throws DataValidationException
Deletes data entries for selectors and notifies subscribers that data entries were deleted.- Parameters:
selectorList- list of selectors for which data should be deleted- Throws:
DataValidationException- if the given selectors are invalid
-
getUseCaseDataValidation
public DataValidation<DATA> getUseCaseDataValidation()
-
setUseCaseDataValidation
public void setUseCaseDataValidation(DataValidation<DATA> useCaseDataValidation)
-
validateData
protected abstract void validateData(DATA data) throws DataValidationExceptionValidates the given data. Must be implemented by the specific Feature Function.- Parameters:
data- the data to validate- Throws:
DataValidationException- if the validation fails
-
getTypeInfo
public TYPE getTypeInfo()
-
-