Record Class TimeRange
java.lang.Object
java.lang.Record
com.inductiveautomation.historian.common.model.TimeRange
- Record Components:
startTime
- the start of the time rangeendTime
- the end of the time range (defaults to now if null)includeBounds
- whether to include points exactly at the boundaries
Represents a time range with optional boundary inclusion.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if a timestamp falls within this time range.static TimeRange
Creates an optional time range, returning null if both times are null.endTime()
Returns the value of theendTime
record component.final boolean
Indicates whether some other object is "equal to" this one.static TimeRange
Creates a time range with exclusive bounds.final int
hashCode()
Returns a hash code value for this object.boolean
Returns the value of theincludeBounds
record component.static TimeRange
Creates a time range with inclusive bounds.Creates a new time range that follows this one without gaps or overlaps.Returns the value of thestartTime
record component.toString()
Returns a string representation of this record class.
-
Constructor Details
-
TimeRange
Primary constructor with validation. -
TimeRange
public TimeRange(long startTimeMillis, long endTimeMillis, boolean includeBounds) Canonical constructor using epoch milliseconds.- Parameters:
startTimeMillis
- the start time in epoch millisecondsendTimeMillis
- the end time in epoch milliseconds, or 0 to use current timeincludeBounds
- whether to include boundary points
-
-
Method Details
-
inclusive
Creates a time range with inclusive bounds.- Parameters:
startTime
- the start timeendTime
- the end time (null for current time)- Returns:
- new time range with inclusive bounds
-
exclusive
Creates a time range with exclusive bounds.- Parameters:
startTime
- the start timeendTime
- the end time (null for current time)- Returns:
- new time range with exclusive bounds
-
create
Creates an optional time range, returning null if both times are null.- Parameters:
startTime
- the start timeendTime
- the end timeincludeBounds
- whether to include boundary points- Returns:
- new time range or null
-
contains
Checks if a timestamp falls within this time range.- Parameters:
timestamp
- the timestamp to check- Returns:
- true if the timestamp is within the range
-
nextRange
Creates a new time range that follows this one without gaps or overlaps.- Returns:
- a new time range starting at this range's end time
-
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. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
startTime
Returns the value of thestartTime
record component.- Returns:
- the value of the
startTime
record component
-
endTime
Returns the value of theendTime
record component.- Returns:
- the value of the
endTime
record component
-
includeBounds
public boolean includeBounds()Returns the value of theincludeBounds
record component.- Returns:
- the value of the
includeBounds
record component
-