java.lang.Object
de.powerstat.validation.containers.HistoryOf<T>
- Type Parameters:
T
- Use only value objects TODO Change Datetime to an earlier Datetime
History of a specific type.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEntry
(OffsetDateTime since, T entry) Add entry.boolean
Is equal with another object.Get first entry from history.Get history.Get latest entry.Get entry before latest entry.int
hashCode()
Calculate hash code.boolean
isEmpty()
Is empty.toString()
Returns the string representation of this HistoryOf.
-
Field Details
-
history
History.
-
-
Constructor Details
-
HistoryOf
public HistoryOf()Constructor.
-
-
Method Details
-
hashCode
public int hashCode()Calculate hash code. -
equals
Is equal with another object.- Overrides:
equals
in classObject
- Parameters:
obj
- Object- Returns:
- true when equal, false otherwise
- Throws:
NoSuchElementException
- If there is no entry in this HistoryOf- See Also:
-
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=?, ...]" -
isEmpty
public boolean isEmpty()Is empty.- Returns:
- true: empty; false otherwise
-
addEntry
Add entry.- Parameters:
since
- Since datetimeentry
- Entry- Throws:
NullPointerException
- If since and/or entry is/are nullIndexOutOfBoundsException
- If since lies in the futureIllegalArgumentException
- If entry is already latest in history
-
getFirstEntry
Get first entry from history.- Returns:
- First known entry
- Throws:
NoSuchElementException
- If there is no entry in this HistoryOf
-
getLatestEntry
Get latest entry.- Returns:
- Latest entry
- Throws:
NoSuchElementException
- If there is no entry in this HistoryOf
-
getPreviousEntry
Get entry before latest entry.- Returns:
- Entry before latest entry
- Throws:
NoSuchElementException
- If there is no entry in this HistoryOf
-
getHistory
Get history.- Returns:
- History sorted map
-