T - generic type of timepoints on the underlying timelinepublic final class SimpleInterval<T> extends Object implements ChronoInterval<T>, Serializable
Generic interval class suitable for any type of timepoints on a timeline.
Represents an interval with following simplified features:
IntervalCollection and IntervalTree. This class is mainly intended to adapt foreign types like java.util.Date. It is serializable
as long as the underlying timeline is serializable.
| Modifier and Type | Class and Description |
|---|---|
static class |
SimpleInterval.Factory<T>
Serves for the creation of generic simple intervals on a timeline.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
abuts(ChronoInterval<T> other)
Queries if this interval abuts the other one such that there is neither any overlap nor any gap between.
|
static SimpleInterval<Date> |
between(Date start,
Date end)
Creates a new interval between given boundaries.
|
static SimpleInterval<Instant> |
between(Instant start,
Instant end)
Creates a new interval between given boundaries.
|
boolean |
contains(ChronoInterval<T> other)
Does this interval contain the other one?
|
boolean |
contains(T temporal)
Queries if given time point belongs to this interval.
|
boolean |
equals(Object obj) |
Optional<SimpleInterval<T>> |
findIntersection(ChronoInterval<T> other)
Obtains the intersection of this interval and other one if present.
|
Boundary<T> |
getEnd()
Yields the upper bound of this interval.
|
Boundary<T> |
getStart()
Yields the lower bound of this interval.
|
int |
hashCode() |
boolean |
isAfter(T temporal)
Is this interval after the given time point?
|
boolean |
isBefore(ChronoInterval<T> other)
Is this interval before the other one?
|
boolean |
isBefore(T temporal)
Is this interval before the given time point?
|
boolean |
isEmpty()
Determines if this interval is empty.
|
static <T> SimpleInterval.Factory<T> |
on(TimeLine<T> timeLine)
Defines a timeline on which new generic intervals can be created.
|
static SimpleInterval.Factory<Instant> |
onInstantTimeLine()
Defines a timeline on which new intervals for the type
java.time.Instant can be created. |
static SimpleInterval.Factory<Date> |
onTraditionalTimeLine()
Defines a timeline on which new intervals for the type
java.util.Date can be created. |
String |
print(ChronoPrinter<T> printer)
Prints this interval using a localized interval pattern.
|
String |
print(ChronoPrinter<T> printer,
String intervalPattern)
Prints this interval in a custom format.
|
static SimpleInterval<Date> |
since(Date start)
Creates a new interval since given start.
|
static SimpleInterval<Instant> |
since(Instant start)
Creates a new interval since given start.
|
String |
toString()
Returns a string in technical notation (suitable for debugging purposes).
|
static SimpleInterval<Date> |
until(Date end)
Creates a new interval until given end.
|
static SimpleInterval<Instant> |
until(Instant end)
Creates a new interval until given end.
|
intersects, isAfter, isFinitepublic static SimpleInterval<Date> between(Date start, Date end)
Creates a new interval between given boundaries.
start - the start of interval (inclusive)end - the end of interval (exclusive)public static SimpleInterval<Instant> between(Instant start, Instant end)
Creates a new interval between given boundaries.
start - the start of interval (inclusive)end - the end of interval (exclusive)MomentInterval.between(Instant, Instant)public static SimpleInterval<Date> since(Date start)
Creates a new interval since given start.
start - the start of interval (inclusive)public static SimpleInterval<Instant> since(Instant start)
Creates a new interval since given start.
start - the start of interval (inclusive)MomentInterval.since(Instant)public static SimpleInterval<Date> until(Date end)
Creates a new interval until given end.
end - the end of interval (exclusive)public static SimpleInterval<Instant> until(Instant end)
Creates a new interval until given end.
end - the end of interval (exclusive)MomentInterval.until(Instant)public static SimpleInterval.Factory<Date> onTraditionalTimeLine()
Defines a timeline on which new intervals for the type java.util.Date can be created.
public static SimpleInterval.Factory<Instant> onInstantTimeLine()
Defines a timeline on which new intervals for the type java.time.Instant can be created.
public static <T> SimpleInterval.Factory<T> on(TimeLine<T> timeLine)
Defines a timeline on which new generic intervals can be created.
T - generic type of timepoints on the underlying timelinetimeLine - the timeline definitionpublic Boundary<T> getStart()
ChronoIntervalYields the lower bound of this interval.
getStart in interface ChronoInterval<T>public Boundary<T> getEnd()
ChronoIntervalYields the upper bound of this interval.
getEnd in interface ChronoInterval<T>public boolean isEmpty()
ChronoIntervalDetermines if this interval is empty.
isEmpty in interface ChronoInterval<T>true if this interval does not contain any time point else falsepublic boolean contains(T temporal)
ChronoIntervalQueries if given time point belongs to this interval.
contains in interface ChronoInterval<T>temporal - time point to be queriedtrue if given time point belongs to this interval else falsepublic boolean contains(ChronoInterval<T> other)
ChronoIntervalDoes this interval contain the other one?
An interval cannot contain infinite intervals but can contain an empty interval if it contains the start anchor of the empty interval.
contains in interface ChronoInterval<T>other - another interval whose relation to this interval is to be investigatedtrue if this interval contains the other one else falseChronoInterval.intersects(ChronoInterval)public boolean isAfter(T temporal)
ChronoIntervalIs this interval after the given time point?
isAfter in interface ChronoInterval<T>temporal - reference time pointtrue if this interval is after given time point else falsepublic boolean isBefore(T temporal)
ChronoIntervalIs this interval before the given time point?
isBefore in interface ChronoInterval<T>temporal - reference time pointtrue if this interval is before given time point else falsepublic boolean isBefore(ChronoInterval<T> other)
ChronoIntervalIs this interval before the other one?
isBefore in interface ChronoInterval<T>other - another interval whose relation to this interval is to be investigatedtrue if this interval is before the other one else falsepublic boolean abuts(ChronoInterval<T> other)
ChronoIntervalQueries if this interval abuts the other one such that there is neither any overlap nor any gap between.
Note: Empty intervals never abut.
abuts in interface ChronoInterval<T>other - another interval which might abut this intervaltrue if there is no intersection and no gap between else falsepublic Optional<SimpleInterval<T>> findIntersection(ChronoInterval<T> other)
Obtains the intersection of this interval and other one if present.
Note that the return type of the method is for the older version line v3.25 or later
just SimpleInterval<T>, possibly returning null.
other - another interval which might have an intersection with this intervalOptional.isPresent(),
ChronoInterval.intersects(ChronoInterval)public String print(ChronoPrinter<T> printer)
Prints this interval using a localized interval pattern.
If given printer does not contain a reference to a locale then the interval pattern "{0}/{1}" will be used.
printer - format object for printing start and endprint(ChronoPrinter, String),
FormatPatternProvider.getIntervalPattern(Locale)public String print(ChronoPrinter<T> printer, String intervalPattern)
Prints this interval in a custom format.
printer - format object for printing start and end componentsintervalPattern - interval pattern containing placeholders {0} and {1} (for start and end)Copyright © 2014–2021. All rights reserved.