Class SlidingValue<T>

  • Type Parameters:
    T - the type of the Value
    Direct Known Subclasses:
    AbstractNumberSlidingValue, LatestSlidingValue

    public abstract class SlidingValue<T>
    extends java.lang.Object
    Calculates the 'Sliding Value' for a value.

    Using the existing subclasses, this class can be used to

    • calculate the average of several numeric values
    • use the latest value for Enum and Boolean values
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void addValue​(T value)
      Adds a value.
      com.google.gson.JsonElement getChangedValueOrNull()
      Gets the value as a JsonElement if it changed.
      protected abstract java.util.Optional<T> getSlidingValue()
      Gets the sliding value, e.g.
      protected OpenemsType getType()
      Gets the OpenemsType of this SlidingValue.
      com.google.gson.JsonElement getValue()
      Gets the value as a JsonElement.
      protected abstract void resetValues()
      Resets the values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SlidingValue

        protected SlidingValue​(OpenemsType type)
    • Method Detail

      • addValue

        public abstract void addValue​(T value)
        Adds a value.
        Parameters:
        value - the value
      • getSlidingValue

        protected abstract java.util.Optional<T> getSlidingValue()
        Gets the sliding value, e.g. the average of all values.
        Returns:
        the sliding value
      • resetValues

        protected abstract void resetValues()
        Resets the values.
      • getType

        protected OpenemsType getType()
        Gets the OpenemsType of this SlidingValue.
        Returns:
        the OpenemsType
      • getChangedValueOrNull

        public com.google.gson.JsonElement getChangedValueOrNull()
        Gets the value as a JsonElement if it changed. Resets the values.
        Returns:
        the value; or null if it had not changed
      • getValue

        public com.google.gson.JsonElement getValue()
        Gets the value as a JsonElement. Resets the values.
        Returns:
        the value; null if is null