T
- the type of itselfpublic interface Temporal<T extends Temporal<T>>
extends java.lang.Comparable<T>
The name of this interface is inspired by the Temporal
.
Provides a default implementation for comparison of two
points in time. It is not supposed that concrete Temporal
s would override this comparison
mechanism.
(is)
option. See TemporalMessage
.Modifier and Type | Method and Description |
---|---|
default int |
compareTo(T other)
Compares this point in time to the given one.
|
default boolean |
isBetween(T periodStart,
T periodEnd)
Checks if this point is time lies between the given.
|
default boolean |
isEarlierOrSameAs(T other)
Checks if this point is time occurs earlier than the other one or they coincide.
|
default boolean |
isEarlierThan(T other)
Checks if this point is time occurs earlier than the other one.
|
default boolean |
isInFuture()
Checks that this point in time lies in the future.
|
default boolean |
isInPast()
Checks that this point in time lies in the past.
|
default boolean |
isLaterOrSameAs(T other)
Checks if this point is time occurs later than the other one or they coincide.
|
default boolean |
isLaterThan(T other)
Checks if this point is time occurs later than the other one.
|
default boolean |
isSameAs(T other)
Checks if this point in time coincides with the given one.
|
com.google.protobuf.Any |
toAny()
Packs this point in time into an
Any . |
default java.time.Instant |
toInstant()
Converts this
Temporal into a Instant . |
com.google.protobuf.Timestamp |
toTimestamp()
Obtains this point in time as a Protobuf
Timestamp . |
com.google.protobuf.Timestamp toTimestamp()
Timestamp
.
The Protobuf Timestamp
represents the UTC Epoch time. All the implementations
should assemble timestamps regarding that fact.
If this Temporal
type lacks precision of the Timestamp
, such as seconds,
nanoseconds, etc., the smallest possible value of Timestamp
should be returned.
For example, if this type represents time up to a minute, the value 01-02-2019 09:40
is translated to the timestamp as if it was 01-02-2019 09:40:00.000000000
(with zero
seconds and zero nanoseconds). Similarly, if the type only represents a year, then
the obtained timestamp points at the 1st of January 00:00:00
of that year.
Timestamp
com.google.protobuf.Any toAny()
Any
.Any
default java.time.Instant toInstant()
Temporal
into a Instant
.Instant
default int compareTo(T other)
The other
point should have the exact runtime type as this one.
Otherwise, an IllegalArgumentException
is thrown. The same constraint is applicable
to all the other comparison methods of Temporal
.
compareTo
in interface java.lang.Comparable<T extends Temporal<T>>
other
- the value to compare toTimestamp
s and compares them.default boolean isEarlierThan(T other)
default boolean isEarlierOrSameAs(T other)
default boolean isLaterThan(T other)
default boolean isLaterOrSameAs(T other)
default boolean isSameAs(T other)
default boolean isBetween(T periodStart, T periodEnd)
All three Temporal
s must exactly the same runtime type. Otherwise,
an IllegalArgumentException
is thrown.
periodStart
- lower bound, exclusiveperiodEnd
- higher bound, inclusivetrue
if this point in time lies in between the given twodefault boolean isInFuture()
Uses Time.currentTime()
to determine the "current" time to compare to.
true
if this point is time is later than the current time,
false
otherwisedefault boolean isInPast()
Uses Time.currentTime()
to determine the "current" time to compare to.
true
if this point is time is earlier than the current time,
false
otherwise