Class TimeSeries

java.lang.Object
org.openhab.core.types.TimeSeries

@NonNullByDefault public class TimeSeries extends Object
The TimeSeries is used to transport a set of states together with their timestamp. It can be used for persisting historic state or forecasts.
Author:
Jan N. Klug - Initial contribution
  • Constructor Details

  • Method Details

    • getPolicy

      public TimeSeries.Policy getPolicy()
      Get the persistence policy of this series.

      TimeSeries.Policy.ADD add the content to the persistence, TimeSeries.Policy.REPLACE first removes all persisted elements in the timespan given by getBegin() and getEnd().

      Returns:
    • getBegin

      public Instant getBegin()
      Get the timestamp of the first element in this series.
      Returns:
      the Instant of the first element
    • getEnd

      public Instant getEnd()
      Get the timestamp of the last element in this series.
      Returns:
      the Instant of the last element
    • size

      public int size()
      Get the number of elements in this series.
      Returns:
      the number of elements
    • add

      public void add(Instant timestamp, State state)
      Add a new element to this series.

      Elements can be added in an arbitrary order and are sorted chronologically.

      Parameters:
      timestamp - an Instant for the given state
      state - the State at the given timestamp
    • getStates

      public Stream<TimeSeries.Entry> getStates()
      Get the content of this series.

      The entries are returned in chronological order, earlier entries before later entries.

      Returns:
      a Stream<TimeSeries.Entry> with the content of this series.
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object