Record Class RelativeDuration
- Record Components:
amount- The signed magnitude; negative is in the past, positive is in the future, relative to request time.unit- The time unit. Must not benull .
[+-]<n>(ms|s|m|h|d) (a request-time offset
that stays a plain literal on the wire).
Pass one to any BeanQuery.Builder/BeanQuery.GroupBuilder comparison method (eq, ne,
gt, gte, lt, lte, between) on a TIMESTAMP or numeric-duration
column to mean "relative to the time the request is evaluated" — for example -24 H
for "24 hours before now." ValueFormat renders this to the exact wire literal below; the search parser
reads that literal back out of a hand-written or stored search string (on a BOOLEAN column it is
BAD_VALUE; on TEXT, ID, ENUM and VERSION columns the text is kept
literally), and the query engine resolves it against one request-time instant
captured once per query (not now()/interval in generated SQL): a TIMESTAMP column's
literal becomes instant ± duration, a numeric-duration column's becomes a plain signed-milliseconds
number. This type is the shared, stable wire format the builder, parser, and engines meet at.
Example:
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe duration unit, with its lowercase wire token (design review ยง3 Gap 2). -
Constructor Summary
ConstructorsConstructorDescriptionRelativeDuration(long amount, RelativeDuration.Unit unit) Compact constructor — validatesunit is non-null . -
Method Summary
Modifier and TypeMethodDescriptionlongamount()Returns the value of theamountrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static RelativeDurationof(long amount, RelativeDuration.Unit unit) Creates a relative-duration literal.static RelativeDurationofDays(long amount) Shorthand forof(amount, Unit.D).static RelativeDurationofHours(long amount) Shorthand forof(amount, Unit.H).static RelativeDurationofMillis(long amount) Shorthand forof(amount, Unit.MS).static RelativeDurationofMinutes(long amount) Shorthand forof(amount, Unit.M).static RelativeDurationofSeconds(long amount) Shorthand forof(amount, Unit.S).final StringtoString()Returns a string representation of this record class.unit()Returns the value of theunitrecord component.
-
Constructor Details
-
RelativeDuration
Compact constructor — validatesunit is non-null .- Parameters:
amount- The signed magnitude.unit- The time unit. Must not benull .
-
-
Method Details
-
of
Creates a relative-duration literal.- Parameters:
amount- The signed magnitude; negative is in the past, positive is in the future.unit- The time unit. Must not benull .- Returns:
- The new literal.
-
ofMillis
Shorthand forof(amount, Unit.MS).- Parameters:
amount- The signed magnitude.- Returns:
- The new literal.
-
ofSeconds
Shorthand forof(amount, Unit.S).- Parameters:
amount- The signed magnitude.- Returns:
- The new literal.
-
ofMinutes
Shorthand forof(amount, Unit.M).- Parameters:
amount- The signed magnitude.- Returns:
- The new literal.
-
ofHours
Shorthand forof(amount, Unit.H).- Parameters:
amount- The signed magnitude.- Returns:
- The new literal.
-
ofDays
Shorthand forof(amount, Unit.D).- Parameters:
amount- The signed magnitude.- Returns:
- The new literal.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
amount
Returns the value of theamountrecord component.- Returns:
- the value of the
amountrecord component
-
unit
Returns the value of theunitrecord component.- Returns:
- the value of the
unitrecord component
-