Class ReadListFeatureFunction<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>
-
- All Implemented Interfaces:
java.lang.AutoCloseable,Shutdownable
- Direct Known Subclasses:
MeasurementFeatureFunction,ReadAndWriteListFeatureFunction
public abstract class ReadListFeatureFunction<DATA,DATA_LIST,SELECTOR,ELEMENTS,TYPE extends ListFeatureFunctionTypeInfo<DATA,DATA_LIST,SELECTOR,ELEMENTS>> extends FeatureFunction
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<ReadListCmdOption>allowedReadListCmdOptionsprotected DataListHolder<DATA,SELECTOR>dataListHolderprotected ListFeatureFunctionNotifier<DATA,DATA_LIST,SELECTOR,ELEMENTS>listFeatureFunctionNotifierprotected static org.slf4j.Loggerlogger-
Fields inherited from class org.openmuc.jeebus.spine.spi.function.FeatureFunction
feature
-
-
Constructor Summary
Constructors Constructor Description ReadListFeatureFunction(java.lang.String functionName, TYPE typeInfo)Constructs a ReadFeatureFunction.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intaddData(DATA addData)Adds given data and notifies subscribers.java.util.List<java.lang.Integer>addData(java.util.List<DATA> addDataList)Adds given data and notifies subscribers.voidclose()Cleanly and promptly shut down this object, as well as all child objects and objects depending on this one.protected java.util.Set<ReadListCmdOption>getAllowedReadCmdOptions()java.util.List<DATA>getDataCopies(java.util.List<java.lang.Integer> idxList)java.util.List<DATA>getDataCopiesFor(java.util.function.Predicate<DATA> predicate)Returns a list of data copies for data that matches given conditionDATAgetDataCopy(int idx)DATAgetDataCopyForFirst(java.util.function.Predicate<DATA> predicate)Returns a copy of the first found data for the given condition.TYPEgetTypeInfo()DataValidation<DATA>getUseCaseDataValidation()org.openmuc.jeebus.spine.xsd.v1.CmdTyperead(org.openmuc.jeebus.spine.xsd.v1.FilterType filter, org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType sourceAddress)voidremoveData(int idx)voidremoveData(java.util.List<java.lang.Integer> idxList)voidsetAllowedReadCmdOptions(ReadListCmdOption... allowedReadListCmdOptions)Sets theReadListCmdOptionthat are allowed to use for the given data.voidsetFeature(Feature feature)This method is automatically called byFeature.addFunction(FeatureFunction).voidsetUseCaseDataValidation(DataValidation<DATA> useCaseDataValidation)voidsetUseCaseReadValidation(ReadListValidation<SELECTOR,ELEMENTS> useCaseReadListValidation)Sets a validation for the read command likevalidateReadCmd(java.util.List<SELECTOR>, ELEMENTS, org.openmuc.jeebus.spine.api.options.ReadListCmdOption).voidupdateData(int idx, DATA update)Updates data at given index by changing to the given update data.voidupdateData(java.util.Map<java.lang.Integer,DATA> updateMap)Updates each of the data from the given map at given index by changing to the given update data.protected abstract voidvalidateData(DATA data)Validates the given data.protected abstract voidvalidateReadCmd(java.util.List<SELECTOR> selectorList, ELEMENTS elements, ReadListCmdOption readListCmdOption)Validates the read command.SpineAcknowledgmentwrite(org.openmuc.jeebus.spine.xsd.v1.CmdType cmd, org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType sourceAddress)-
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
-
dataListHolder
protected final DataListHolder<DATA,SELECTOR> dataListHolder
-
listFeatureFunctionNotifier
protected final ListFeatureFunctionNotifier<DATA,DATA_LIST,SELECTOR,ELEMENTS> listFeatureFunctionNotifier
-
allowedReadListCmdOptions
protected java.util.Set<ReadListCmdOption> allowedReadListCmdOptions
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Detail
-
ReadListFeatureFunction
public ReadListFeatureFunction(java.lang.String functionName, TYPE typeInfo)Constructs a ReadFeatureFunction. If FeatureFunction shall be none identifiable use an emptyDataIdDescriptionby usingDataIdDescription.getNoneIdentifiableDataDescription(Class). This class automatically executes read 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
-
-
Method Detail
-
getAllowedReadCmdOptions
protected java.util.Set<ReadListCmdOption> getAllowedReadCmdOptions()
-
setAllowedReadCmdOptions
public void setAllowedReadCmdOptions(ReadListCmdOption... allowedReadListCmdOptions)
Sets theReadListCmdOptionthat are allowed to use for the given data.- Parameters:
allowedReadListCmdOptions- allowed options
-
setUseCaseReadValidation
public void setUseCaseReadValidation(ReadListValidation<SELECTOR,ELEMENTS> useCaseReadListValidation)
Sets a validation for the read command likevalidateReadCmd(java.util.List<SELECTOR>, ELEMENTS, org.openmuc.jeebus.spine.api.options.ReadListCmdOption). Should be set by the Use Case Implementation. ThrowsSpineExceptionif the validation fails.- Parameters:
useCaseReadListValidation- functional interface functionReadListValidation
-
validateReadCmd
protected abstract void validateReadCmd(java.util.List<SELECTOR> selectorList, ELEMENTS elements, ReadListCmdOption readListCmdOption) throws SpineException
Validates the read command. Must be implemented by the specific Feature Function. ThrowsSpineExceptionif the validation fails.- Parameters:
selectorList- the list of given selectors, may be emptyelements- the elementsType object, may be nullreadListCmdOption- the CmdOption that was used by the request- Throws:
SpineException- if the validation fails
-
read
public org.openmuc.jeebus.spine.xsd.v1.CmdType read(org.openmuc.jeebus.spine.xsd.v1.FilterType filter, org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType sourceAddress) throws SpineException- Specified by:
readin classFeatureFunction- Parameters:
filter- filter for partial read otherwise nullsourceAddress- the feature address of the client feature- Returns:
- an
CmdTypeinstance filled with the requested information - Throws:
SpineException- on invalid filter
-
write
public SpineAcknowledgment write(org.openmuc.jeebus.spine.xsd.v1.CmdType cmd, org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType sourceAddress) throws SpineException
- Specified by:
writein classFeatureFunction- 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
-
getDataCopy
public DATA getDataCopy(int idx)
-
getDataCopyForFirst
public DATA getDataCopyForFirst(java.util.function.Predicate<DATA> predicate)
Returns a copy of the first found data for the given condition.- Parameters:
predicate- the condition- Returns:
- copy of the first found data, null if none is found
-
getDataCopiesFor
public java.util.List<DATA> getDataCopiesFor(java.util.function.Predicate<DATA> predicate)
Returns a list of data copies for data that matches given condition- Parameters:
predicate- the condition- Returns:
- list of data copies
-
getDataCopies
public java.util.List<DATA> getDataCopies(java.util.List<java.lang.Integer> idxList)
-
updateData
public void updateData(int idx, DATA update) throws DataValidationExceptionUpdates data at given index by changing to the given update data.- Parameters:
idx- the idx of the data that should be updatedupdate- the update data- Throws:
DataValidationException- if data validation fails
-
updateData
public void updateData(java.util.Map<java.lang.Integer,DATA> updateMap) throws DataValidationException
Updates each of the data from the given map at given index by changing to the given update data.- Parameters:
updateMap- map of updates with idx and data as entries- Throws:
DataValidationException- if data validation fails
-
addData
public int addData(DATA addData) throws DataValidationException
Adds given data and notifies subscribers.- Parameters:
addData- data to add- Returns:
- idx of the added data
- Throws:
DataValidationException- if data validation fails
-
addData
public java.util.List<java.lang.Integer> addData(java.util.List<DATA> addDataList) throws DataValidationException
Adds given data and notifies subscribers.- Parameters:
addDataList- data to add- Returns:
- list of indices for each of the added data in order of the given list
- Throws:
DataValidationException- if data validation fails
-
removeData
public void removeData(java.util.List<java.lang.Integer> idxList)
-
removeData
public void removeData(int idx)
-
setFeature
public void setFeature(Feature feature)
Description copied from class:FeatureFunctionThis method is automatically called byFeature.addFunction(FeatureFunction).- Overrides:
setFeaturein classFeatureFunction- Parameters:
feature- the SPINE feature this function belongs to
-
close
public void close()
Description copied from interface:ShutdownableCleanly and promptly shut down this object, as well as all child objects and objects depending on this one.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceShutdownable
-
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()
-
-