Package codes.grow.packages.skywalking
Record Class TimeRange
java.lang.Object
java.lang.Record
codes.grow.packages.skywalking.TimeRange
- Record Components:
start- window start, or empty forend − 1 hend- window end, or empty for nowstep- bucket granularity, or empty forStep.MINUTE
public record TimeRange(Optional<Instant> start, Optional<Instant> end, Optional<Step> step)
extends Record
Time window of a metadata, topology, trace or log query. Defaults:
end = now,
start = end − 1 h (DEFAULT_WINDOW), step = Step.MINUTE. OAP
expects the bounds in its own time zone; the client converts them.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionend()Returns the value of theendrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanWhether no bound and no step is set.static TimeRangeThe lastwindowuntil now (resolved when the query runs).static TimeRangeA window between two instants (either may be null).Applies the defaults and validates.static TimeRangeA window fromstartto now.start()Returns the value of thestartrecord component.step()Returns the value of thesteprecord component.final StringtoString()Returns a string representation of this record class.Returns a copy with another step.
-
Field Details
-
DEFAULT_WINDOW
Default query window: one hour. -
DEFAULT
Everything defaulted: the last hour, step MINUTE.
-
-
Constructor Details
-
TimeRange
Normalises nulls.- Parameters:
start- startend- endstep- step
-
-
Method Details
-
of
A window between two instants (either may be null).- Parameters:
start- start or nullend- end or null- Returns:
- the range
-
since
A window fromstartto now.- Parameters:
start- start- Returns:
- the range
-
last
The lastwindowuntil now (resolved when the query runs).- Parameters:
window- positive duration- Returns:
- the range
-
withStep
Returns a copy with another step.- Parameters:
step- step- Returns:
- the range
-
isDefault
public boolean isDefault()Whether no bound and no step is set.- Returns:
- true when everything is defaulted
-
resolve
Applies the defaults and validates.- Parameters:
now- current timeoperation- operation name for the error- Returns:
- the resolved window
- Throws:
ValidationException- when start is after end
-
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
public final int 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. All components in this record class are compared withObjects::equals(Object,Object). -
start
Returns the value of thestartrecord component.- Returns:
- the value of the
startrecord component
-
end
Returns the value of theendrecord component.- Returns:
- the value of the
endrecord component
-
step
Returns the value of thesteprecord component.- Returns:
- the value of the
steprecord component
-