Class ReadAndWriteListFeatureFunction<DATA,​DATA_LIST,​SELECTOR,​ELEMENTS,​TYPE extends ListFeatureFunctionTypeInfo<DATA,​DATA_LIST,​SELECTOR,​ELEMENTS>>

    • Field Detail

      • 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 empty DataIdDescription by using DataIdDescription.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 function
        typeInfo - the RTTI object for this feature function
    • Method Detail

      • setUseCaseWriteValidationFull

        public void setUseCaseWriteValidationFull​(WriteListValidationFull<DATA,​SELECTOR,​ELEMENTS> writeValidationFull)
        Validates the write command like validateWriteCmd(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 - the WriteListValidationFull function 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()
      • 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 added
        dataUpdateType - if the data shall be updated, deleted or newly added
        idx - 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 update
        matchingData - the data that is to be changed by the update
        writeListCmdOption - the WriteListCmdOption that 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 the WriteListCmdOption that 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 empty
        elements - the elementsType object, may be null
        writeListCmdOption - the WriteListCmdOption that is used
        Throws:
        SpineException - if the validation fails
      • 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 DataValidationException
        Validates 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()