Class HistoryOf<T>

java.lang.Object
de.powerstat.validation.containers.HistoryOf<T>
Type Parameters:
T - Use only value objects TODO Change Datetime to an earlier Datetime

public class HistoryOf<T> extends Object
History of a specific type.
  • Field Details

  • Constructor Details

    • HistoryOf

      public HistoryOf()
      Constructor.
  • Method Details

    • hashCode

      public int hashCode()
      Calculate hash code.
      Overrides:
      hashCode in class Object
      Returns:
      Hash
      See Also:
    • equals

      public boolean equals(Object obj)
      Is equal with another object.
      Overrides:
      equals in class Object
      Parameters:
      obj - Object
      Returns:
      true when equal, false otherwise
      Throws:
      NoSuchElementException - If there is no entry in this HistoryOf
      See Also:
    • toString

      public String toString()
      Returns the string representation of this HistoryOf. The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical: "HistoryOf<>[2020-01-11T21:10:00+01=?, ...]"
      Overrides:
      toString in class Object
      Returns:
      String representation of this HistoryOf
      See Also:
    • isEmpty

      public boolean isEmpty()
      Is empty.
      Returns:
      true: empty; false otherwise
    • addEntry

      public void addEntry(OffsetDateTime since, T entry)
      Add entry.
      Parameters:
      since - Since datetime
      entry - Entry
      Throws:
      NullPointerException - If since and/or entry is/are null
      IndexOutOfBoundsException - If since lies in the future
      IllegalArgumentException - If entry is already latest in history
    • getFirstEntry

      public T getFirstEntry()
      Get first entry from history.
      Returns:
      First known entry
      Throws:
      NoSuchElementException - If there is no entry in this HistoryOf
    • getLatestEntry

      public T getLatestEntry()
      Get latest entry.
      Returns:
      Latest entry
      Throws:
      NoSuchElementException - If there is no entry in this HistoryOf
    • getPreviousEntry

      public T getPreviousEntry()
      Get entry before latest entry.
      Returns:
      Entry before latest entry
      Throws:
      NoSuchElementException - If there is no entry in this HistoryOf
    • getHistory

      public SortedMap<OffsetDateTime,T> getHistory()
      Get history.
      Returns:
      History sorted map