Class ReadSingleFeatureFunction<DATA,ELEMENTS,TYPE extends DataFeatureFunctionTypeInfo<DATA,ELEMENTS>>
- java.lang.Object
-
- org.openmuc.jeebus.spine.spi.function.FeatureFunction
-
- org.openmuc.jeebus.spine.spi.function.ReadSingleFeatureFunction<DATA,ELEMENTS,TYPE>
-
- All Implemented Interfaces:
java.lang.AutoCloseable,Shutdownable
- Direct Known Subclasses:
NodeDataFunction,ReadAndWriteSingleFeatureFunction,ServiceDataFunction,StateDataFunction
public abstract class ReadSingleFeatureFunction<DATA,ELEMENTS,TYPE extends DataFeatureFunctionTypeInfo<DATA,ELEMENTS>> extends FeatureFunction
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<ReadSingleCmdOption>allowedReadCmdOptionsprotected DATAdataprotected java.lang.ObjectdataLockprotected static org.slf4j.Loggerlogger-
Fields inherited from class org.openmuc.jeebus.spine.spi.function.FeatureFunction
feature
-
-
Constructor Summary
Constructors Constructor Description ReadSingleFeatureFunction(java.lang.String functionName, TYPE typeInfo)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Cleanly and promptly shut down this object, as well as all child objects and objects depending on this one.java.util.Set<ReadSingleCmdOption>getAllowedReadCmdOptions()DATAgetDataCopy()Returns a data copy of the current data.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)voidsetAllowedReadCmdOptions(ReadSingleCmdOption... allowedReadCmdOptions)voidsetUseCaseDataValidation(DataValidation<DATA> useCaseDataValidation)voidsetUseCaseReadSingleDataValidation(ReadSingleDataValidation<ELEMENTS> useCaseReadListValidation)voidupdateData(DATA update)Updates the data for the given update.protected abstract voidvalidateData(DATA data)Validates the given data.protected abstract voidvalidateReadCmd(ELEMENTS elements, ReadSingleCmdOption readListCmdOption)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, setFeature, setReadable, setWritable
-
-
-
-
Field Detail
-
data
protected DATA data
-
dataLock
protected final java.lang.Object dataLock
-
allowedReadCmdOptions
protected java.util.Set<ReadSingleCmdOption> allowedReadCmdOptions
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Detail
-
ReadSingleFeatureFunction
public ReadSingleFeatureFunction(java.lang.String functionName, TYPE typeInfo)
-
-
Method Detail
-
getAllowedReadCmdOptions
public java.util.Set<ReadSingleCmdOption> getAllowedReadCmdOptions()
-
setAllowedReadCmdOptions
public void setAllowedReadCmdOptions(ReadSingleCmdOption... allowedReadCmdOptions)
-
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
-
setUseCaseReadSingleDataValidation
public void setUseCaseReadSingleDataValidation(ReadSingleDataValidation<ELEMENTS> useCaseReadListValidation)
-
validateReadCmd
protected abstract void validateReadCmd(ELEMENTS elements, ReadSingleCmdOption readListCmdOption) throws SpineException
- Throws:
SpineException
-
updateData
public void updateData(DATA update) throws DataValidationException
Updates the data for the given update. Validates the update before and throws DataValidationException if invalid. Notifies subscribers on successful update. Any elements that are set to null in the update will be notified as deleted.- Parameters:
update- the update- Throws:
DataValidationException- if data validation fails
-
getDataCopy
public DATA getDataCopy()
Returns a data copy of the current data.- Returns:
- data copy
-
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()
-
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.
-
-