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

    • Constructor Detail

      • ReadListFeatureFunction

        public ReadListFeatureFunction​(java.lang.String functionName,
                                       TYPE typeInfo)
        Constructs a ReadFeatureFunction. If FeatureFunction shall be none identifiable use an empty DataIdDescription by using DataIdDescription.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 function
        typeInfo - the RTTI object
    • Method Detail

      • getAllowedReadCmdOptions

        protected java.util.Set<ReadListCmdOption> getAllowedReadCmdOptions()
      • setAllowedReadCmdOptions

        public void setAllowedReadCmdOptions​(ReadListCmdOption... allowedReadListCmdOptions)
        Sets the ReadListCmdOption that are allowed to use for the given data.
        Parameters:
        allowedReadListCmdOptions - allowed options
      • 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. Throws SpineException if the validation fails.
        Parameters:
        selectorList - the list of given selectors, may be empty
        elements - the elementsType object, may be null
        readListCmdOption - 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:
        read in class FeatureFunction
        Parameters:
        filter - filter for partial read otherwise null
        sourceAddress - the feature address of the client feature
        Returns:
        an CmdType instance 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:
        write in class FeatureFunction
        Parameters:
        cmd - to be written data including optional filters for restricted function exchange
        sourceAddress - 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 DataValidationException
        Updates data at given index by changing to the given update data.
        Parameters:
        idx - the idx of the data that should be updated
        update - 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 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)
      • close

        public void close()
        Description copied from interface: Shutdownable
        Cleanly and promptly shut down this object, as well as all child objects and objects depending on this one.

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface Shutdownable
      • 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()