public final class TimePeriodInfo extends Object
Serialized as JSON: {"min":1.5,"max":2} (seconds with decimals).
UNKNOWN (min < 0 && max < 0) means "not set / unknown"
(no info available). Serializes as {"min":-1,"max":-1}.
EMPTY (min == 0 && max == 0) means "known to be zero"
(e.g. zero duration / instant). Serializes as {"min":0,"max":0}.
The wire sentinel for UNKNOWN is {"min":-1,"max":-1}.
On parsing, any negative values in the JSON are treated as UNKNOWN (see valueOf(String)).
Non-Java consumers that receive -1 seconds should interpret it as
"no information available" rather than as a literal negative time period.
| Modifier and Type | Field and Description |
|---|---|
static TimePeriodInfo |
EMPTY
Sentinel value meaning "known to be zero".
|
static TimePeriodInfo |
UNKNOWN
Sentinel value meaning "not set / unknown".
|
| Modifier and Type | Method and Description |
|---|---|
TimePeriodInfo |
add(long period)
Convenience overload that aggregates a single-period value.
|
TimePeriodInfo |
add(TimePeriodInfo other)
Returns a new
TimePeriodInfo that is the aggregate of this and the given info. |
boolean |
equals(Object o) |
long |
getMax()
Returns the maximum period in milliseconds.
|
long |
getMin()
Returns the minimum period in milliseconds.
|
int |
hashCode() |
boolean |
isUnknown()
Returns
true if this is the UNKNOWN sentinel value. |
String |
toString()
Returns JSON format:
{"min":1.5,"max":2.0} (seconds with decimals). |
static TimePeriodInfo |
valueOf(long min,
long max)
|
static TimePeriodInfo |
valueOf(String value)
Parses from JSON format:
{"min":1.5,"max":2.0} (seconds with decimals). |
public static final TimePeriodInfo UNKNOWN
min and max.public static final TimePeriodInfo EMPTY
min == 0 and max == 0.public static TimePeriodInfo valueOf(long min, long max)
min - minimum period in milliseconds (non-negative)max - maximum period in milliseconds (non-negative, >= min)IllegalArgumentException - if min or max is negative or min > maxpublic static TimePeriodInfo valueOf(String value)
{"min":1.5,"max":2.0} (seconds with decimals).
Wire parsing is lenient: any malformed or semantically invalid input — null, empty,
unparseable, negative bounds, or min > max — is mapped to UNKNOWN
rather than thrown. This keeps the sentinel {"min":-1,"max":-1} round-tripping
correctly and protects consumers from peer-side bugs in wire data.value - JSON string to parseUNKNOWN if the string is null, empty, or invalidpublic long getMin()
UNKNOWN, returns a negative sentinel value.
Use isUnknown() to check before using this value arithmetically.public long getMax()
UNKNOWN, returns a negative sentinel value.
Use isUnknown() to check before using this value arithmetically.public boolean isUnknown()
true if this is the UNKNOWN sentinel value.public TimePeriodInfo add(TimePeriodInfo other)
TimePeriodInfo that is the aggregate of this and the given info.
The result has the minimum of both mins and the maximum of both maxes.
UNKNOWN is the identity element: UNKNOWN.add(x) returns x,
x.add(UNKNOWN) returns x, UNKNOWN.add(UNKNOWN) returns UNKNOWN.other - the info to aggregate withpublic TimePeriodInfo add(long period)
period - period in milliseconds (must be non-negative)IllegalArgumentException - if the period is negativepublic String toString()
{"min":1.5,"max":2.0} (seconds with decimals).
UNKNOWN serializes as {"min":-1,"max":-1} — any negative values
on the wire are treated as UNKNOWN by valueOf(String).
All instances return valid JSON.Copyright © 2002–2026 Devexperts LLC. All rights reserved.