T
- The type of the Data
(get
) associated with the interval.public final class TimeInterval1<T> extends Object implements IEquatable<TimeInterval1<T>>, IEquatableEpsilon<TimeInterval1<T>>
Modifier and Type | Field and Description |
---|---|
static IEqualityComparer |
DefaultComparer
|
Constructor and Description |
---|
TimeInterval1(JulianDate start,
JulianDate stop)
Initializes a new interval with the specified start date and stop date.
|
TimeInterval1(JulianDate start,
JulianDate stop,
boolean isStartIncluded,
boolean isStopIncluded)
Initializes a new interval with the specified start date and stop date,
also specifying whether the start and stop dates are included.
|
TimeInterval1(JulianDate start,
JulianDate stop,
T data)
Initializes a new interval with the specified start date, stop date, and data.
|
TimeInterval1(JulianDate start,
JulianDate stop,
T data,
boolean isStartIncluded,
boolean isStopIncluded)
Initializes a new interval with the specified start date, stop date, and data,
also specifying whether the start and stop dates are included.
|
Modifier and Type | Method and Description |
---|---|
TimeIntervalCollection1<T> |
add(TimeInterval1<T> other)
Adds two intervals together, producing an interval list that
includes both intervals.
|
TimeIntervalCollection1<T> |
add(TimeIntervalCollection1<T> intervalList)
Adds an interval list to this interval, producing a new interval list
that includes this interval plus all intervals in the input list.
|
<TNew> TimeInterval1<TNew> |
changeData(TNew newData)
Creates a new interval that is identical to this time interval,
except that it has a different value for the
Data (get ) property. |
boolean |
contains(JulianDate date)
Determines if the interval contains a specified date.
|
boolean |
equals(Object obj)
Indicates whether another object is exactly equal to this instance.
|
boolean |
equals(TimeInterval1<T> other,
IEqualityComparer<T> dataComparer)
Indicates whether another instance of this type is exactly equal to this instance.
|
static <T> boolean |
equals(TimeInterval1<T> left,
TimeInterval1<T> right)
Returns
true if the two instances are exactly equal. |
boolean |
equalsEpsilon(TimeInterval1<T> other,
double epsilon)
|
boolean |
equalsEpsilon(TimeInterval1<T> other,
double epsilon,
IEqualityComparer<T> dataComparer)
|
boolean |
equalsType(TimeInterval1<T> other)
Indicates whether another instance of this type is exactly equal to this instance.
|
static <T> MergeTimeIntervalDataCallback<T> |
getAcceptLeft()
Gets a
MergeTimeIntervalDataCallback that simply accepts the data on the left-hand side. |
static <T> MergeTimeIntervalDataCallback<T> |
getAcceptRight()
Gets a
MergeTimeIntervalDataCallback that simply accepts the data on the right-hand side. |
T |
getData()
Gets the user-defined data associated with this interval.
|
static <T> TimeInterval1<T> |
getEmpty()
Gets an empty interval.
|
int |
getHashCode(IEqualityComparer<T> dataComparer)
Returns a hash code for this instance, which is suitable for use in hashing algorithms and data structures like a hash table.
|
boolean |
getIsEmpty()
Gets a value indicating whether the interval is empty.
|
boolean |
getIsStartIncluded()
Gets a value indicating whether the
Start (get ) date is included in the interval. |
boolean |
getIsStopIncluded()
Gets a value indicating whether the
Stop (get ) date is included in the interval. |
JulianDate |
getStart()
Gets the start date of the interval.
|
JulianDate |
getStop()
Gets the stop date of the interval.
|
int |
hashCode()
Returns a hash code for this instance, which is suitable for use in hashing algorithms and data structures like a hash table.
|
TimeInterval1<T> |
intersect(TimeInterval other)
Computes an interval which is the intersection of this interval with another,
with the data from this one.
|
TimeInterval1<T> |
intersect(TimeInterval1<T> other)
Computes an interval which is the intersection of this interval with another.
|
TimeInterval1<T> |
intersect(TimeInterval1<T> other,
IEqualityComparer<T> dataComparer)
Computes an interval which is the intersection of this interval with another.
|
TimeInterval1<T> |
intersectMergingData(TimeInterval1<T> other,
MergeTimeIntervalDataCallback<T> mergeCallback)
Computes an interval which is the intersection of this interval with another while
also providing a means to merge the data of the two intervals.
|
static <T> boolean |
notEquals(TimeInterval1<T> left,
TimeInterval1<T> right)
Returns
true if the two instances are not exactly equal. |
TimeInterval |
removeData()
Creates a new interval that is identical to this one except that it does not have a
Data (get ) property. |
Duration |
toDuration()
|
String |
toString()
Returns a string with interval in the format "[Start, Stop) - Data".
|
TimeInterval1<T> |
toTimeStandard(TimeStandard timeStandard)
Returns a
TimeInterval1 equivalent to this one where the time standard
of the start and end dates has been converted to the specified standard. |
@Nonnull public static final IEqualityComparer DefaultComparer
public TimeInterval1(@Nonnull JulianDate start, @Nonnull JulianDate stop)
start
- The first date in the interval.stop
- The last date in the interval.public TimeInterval1(@Nonnull JulianDate start, @Nonnull JulianDate stop, T data)
start
- The first date in the interval.stop
- The last date in the interval.data
- The user-defined data associated with this interval.public TimeInterval1(@Nonnull JulianDate start, @Nonnull JulianDate stop, boolean isStartIncluded, boolean isStopIncluded)
start
- The date that starts the interval.stop
- The date that stops the interval.isStartIncluded
- true if the start date is included in the interval.isStopIncluded
- true if the stop date is included in the interval.public TimeInterval1(@Nonnull JulianDate start, @Nonnull JulianDate stop, T data, boolean isStartIncluded, boolean isStopIncluded)
start
- The date that starts the interval.stop
- The date that stops the interval.data
- The user-defined data associated with this interval.isStartIncluded
- true if the start date is included in the interval.isStopIncluded
- true if the stop date is included in the interval.@Nonnull public final JulianDate getStart()
@Nonnull public final JulianDate getStop()
public final boolean getIsStartIncluded()
Start
(get
) date is included in the interval.public final boolean getIsStopIncluded()
Stop
(get
) date is included in the interval.public final T getData()
public final boolean getIsEmpty()
TimeInterval1.toDuration()
and check for equality with Zero
(get
).@Nonnull public final Duration toDuration()
Duration
representing the span of time between the
Start
(get
) and Stop
(get
) of the interval.@Nonnull public final TimeInterval1<T> toTimeStandard(TimeStandard timeStandard)
TimeInterval1
equivalent to this one where the time standard
of the start and end dates has been converted to the specified standard.timeStandard
- The time standard of the new interval.@Nonnull public final TimeInterval1<T> intersect(@Nullable TimeInterval1<T> other)
TimeInterval1.DefaultComparer
is used to compare the Data
(get
) properties of this interval
and the other
interval. If the comparer reports that the Data
(get
) properties are not
equal, the intersection is an empty interval. If the comparer reports that the Data
(get
) properties
are equal, the new interval representing the intersection will have the same value for its Data
(get
)
property as the interval on which this method is called.
other
- The interval to intersect with this interval.@Nonnull public final TimeInterval1<T> intersect(@Nullable TimeInterval1<T> other, @Nonnull IEqualityComparer<T> dataComparer)
dataComparer
is used to compare the Data
(get
) properties of this interval
and the other
interval. If the comparer reports that the Data
(get
) properties are not
equal, the intersection is an empty interval. If the comparer reports that the Data
(get
) properties
are equal, the new interval representing the intersection will have the same value for its Data
(get
)
property as the interval on which this method is called.
other
- The interval to intersect with this interval.dataComparer
- The object to use to compare the Data
(get
) properties of the two intervals.@Nonnull public final TimeInterval1<T> intersect(@Nonnull TimeInterval other)
other
- The interval to intersect with this interval.@Nonnull public final TimeInterval1<T> intersectMergingData(@Nullable TimeInterval1<T> other, @Nullable MergeTimeIntervalDataCallback<T> mergeCallback)
other
- The interval to intersect with this interval.mergeCallback
- A callback to use to 'merge' the data on the two intervals, or null. If this interval
intersects with the other
one, the two data instances will be merged with this callback
to create the data on the resulting interval. If the callback is null, this will intersect the two
intervals and return the new interval with the data from 'this' interval.@Nonnull public final TimeIntervalCollection1<T> add(@Nullable TimeInterval1<T> other)
other
- The interval to add.@Nonnull public final TimeIntervalCollection1<T> add(@Nullable TimeIntervalCollection1<T> intervalList)
intervalList
- The interval list to add.public final boolean contains(@Nonnull JulianDate date)
date
- The date to test.true
if the interval contains the date; otherwise false
.@Nonnull public final <TNew> TimeInterval1<TNew> changeData(TNew newData)
Data
(get
) property.TNew
- The type of the new data.newData
- The new value for the Data
(get
) property.@Nonnull public final TimeInterval removeData()
Data
(get
) property.public final boolean equalsEpsilon(TimeInterval1<T> other, double epsilon)
Start
(get
) and Stop
(get
) properties of the
two intervals. The dates are considered equal if they are within epsilon
seconds of each other. All other properties must be identical.equalsEpsilon
in interface IEquatableEpsilon<TimeInterval1<T>>
other
- The time interval to compare to this time interval.epsilon
- The largest difference between the Start
(get
) and Stop
(get
) dates, in seconds, such that they will be considered equal.Start
(get
) and Stop
(get
) dates of the intervals are equal as defined by the epsilon value and all other properties are identical.public final boolean equalsEpsilon(TimeInterval1<T> other, double epsilon, @Nonnull IEqualityComparer<T> dataComparer)
Start
(get
) and Stop
(get
) properties of the
two intervals. The dates are considered equal if they are within epsilon
seconds of each other. All other properties must be identical.other
- The time interval to compare to this time interval.epsilon
- The largest difference between the Start
(get
) and Stop
(get
) dates, in seconds, such that they will be considered equal.dataComparer
- The object to use to compare the Data
(get
) properties of the two intervals.Start
(get
) and Stop
(get
) dates of the intervals are equal as defined by the epsilon value and all other properties are identical.public final boolean equalsType(TimeInterval1<T> other)
equalsType
in interface IEquatable<TimeInterval1<T>>
other
- The instance to compare to this instance.true
if other
represents the same value as this instance; otherwise false
.public final boolean equals(TimeInterval1<T> other, @Nonnull IEqualityComparer<T> dataComparer)
other
- The instance to compare to this instance.dataComparer
- The object to use to compare the Data
(get
) properties of the two intervals.true
if other
represents the same value as this instance; otherwise false
.public boolean equals(Object obj)
equals
in class Object
obj
- The object to compare to this instance.true
if obj
is an instance of this type and represents the same value as this instance; otherwise false
.Object.hashCode()
,
HashMap
public String toString()
public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public final int getHashCode(@Nonnull IEqualityComparer<T> dataComparer)
dataComparer
- The object to use to retrieve the hash code for the Data
(get
) property of the interval.public static <T> boolean equals(TimeInterval1<T> left, TimeInterval1<T> right)
true
if the two instances are exactly equal.left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
represents the same value as right
; otherwise false
.public static <T> boolean notEquals(TimeInterval1<T> left, TimeInterval1<T> right)
true
if the two instances are not exactly equal.left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
does not represent the same value as right
; otherwise false
.@Nonnull public static <T> MergeTimeIntervalDataCallback<T> getAcceptLeft()
MergeTimeIntervalDataCallback
that simply accepts the data on the left-hand side.@Nonnull public static <T> MergeTimeIntervalDataCallback<T> getAcceptRight()
MergeTimeIntervalDataCallback
that simply accepts the data on the right-hand side.@Nonnull public static <T> TimeInterval1<T> getEmpty()