T - temporal type of time points within a given intervalI - generic self-referencing interval typepublic abstract class IsoInterval<T extends Temporal<? super T>,I extends IsoInterval<T,I>> extends Object implements ChronoInterval<T>
Represents an abstract temporal interval on a timeline for ISO-8601-types.
Note that the start of an interval is (almost) always included (with the exception of intervals with infinite past). The end is open for intervals with infinite future and else included for date intervals by default and excluded for other interval types. This default setting can be overwritten however (although potentially harmful for the performance).
| 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.
|
I |
collapse()
Changes this interval to an empty interval with the same
start anchor.
|
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 |
enclosedBy(I other)
ALLEN-relation: Equivalent to
other.encloses(this). |
boolean |
encloses(I other)
ALLEN-relation: Does this interval enclose the other one such that
this start is before the start of the other one and this end is after
the end of the other one?
|
boolean |
equals(Object obj)
Compares the boundaries (start and end) and also the time axis
of this and the other interval.
|
boolean |
equivalentTo(I other)
ALLEN-relation: Does this interval equal the other one taking into
account the open or closed state of the boundaries?
|
Optional<I> |
findIntersection(ChronoInterval<T> other)
Obtains the intersection of this interval and other one if present.
|
boolean |
finishedBy(I other)
ALLEN-relation: Equivalent to
other.finishes(this). |
boolean |
finishes(I other)
ALLEN-relation: Does this interval finish the other one such that
both end time points are equal and the start of this interval is after
the start of the other one?
|
<R> R |
get(ChronoFunction<ChronoInterval<T>,R> function)
Lets given query evaluate this interval.
|
Boundary<T> |
getEnd()
Yields the upper bound of this interval.
|
Boundary<T> |
getStart()
Yields the lower bound of this interval.
|
int |
hashCode() |
boolean |
intersects(ChronoInterval<T> other)
Queries if this interval intersects the other one such that there is at least one common time point.
|
boolean |
isAfter(ChronoInterval<T> other)
Is this interval after the other one?
|
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.
|
boolean |
meets(I other)
ALLEN-relation: Does this interval precede the other one such that
there is no gap between?
|
boolean |
metBy(I other)
ALLEN-relation: Equivalent to
other.meets(this). |
boolean |
overlappedBy(I other)
ALLEN-relation: Equivalent to
other.overlaps(this). |
boolean |
overlaps(I other)
ALLEN-relation: Does this interval overlaps the other one such that
the start of this interval is still before the start of the other
one?
|
boolean |
precededBy(I other)
ALLEN-relation: Equivalent to
other.precedes(this). |
boolean |
precedes(I other)
ALLEN-relation: Does this interval precede the other one such that
there is a gap between?
|
String |
print(ChronoPrinter<T> printer)
Prints the canonical form of this interval using a localized interval pattern.
|
String |
print(ChronoPrinter<T> printer,
BracketPolicy policy)
Prints the start and end separated by a slash using given formatter (technical format).
|
void |
print(ChronoPrinter<T> startFormat,
char separator,
ChronoPrinter<T> endFormat,
BracketPolicy policy,
Appendable buffer)
Deprecated.
Use the variant with explicit infinity style argument instead
|
void |
print(ChronoPrinter<T> startFormat,
char separator,
ChronoPrinter<T> endFormat,
BracketPolicy policy,
InfinityStyle infinityStyle,
Appendable buffer)
Prints this interval in a technical format using given formatters and separator.
|
String |
print(ChronoPrinter<T> printer,
String intervalPattern)
Prints the canonical form of this interval in a custom format.
|
boolean |
startedBy(I other)
ALLEN-relation: Equivalent to
other.starts(this). |
boolean |
starts(I other)
ALLEN-relation: Does this interval start the other one such that both
start time points are equal and the end of this interval is before the
end of the other one?
|
I |
toCanonical()
Changes this interval to an interval such that calendrical intervals become closed intervals
and other intervals become half-open.
|
String |
toString()
Yields a descriptive string using the standard output
of the method
toString() of start and end. |
I |
withClosedEnd()
Includes the upper boundary of this interval.
|
I |
withClosedStart()
Includes the lower boundary of this interval.
|
I |
withEnd(T temporal)
Yields a copy of this interval with given end time.
|
I |
withEnd(UnaryOperator<T> operator)
Yields a copy of this interval with given operator applied on end time.
|
I |
withOpenEnd()
Excludes the upper boundary from this interval.
|
I |
withOpenStart()
Excludes the lower boundary from this interval.
|
I |
withStart(T temporal)
Yields a copy of this interval with given start time.
|
I |
withStart(UnaryOperator<T> operator)
Yields a copy of this interval with given operator applied on start time.
|
<V> ValueInterval<T,I,V> |
withValue(V value)
Creates a combination of this interval with an associated value.
|
isFinitepublic final Boundary<T> getStart()
ChronoIntervalYields the lower bound of this interval.
getStart in interface ChronoInterval<T extends Temporal<? super T>>public final Boundary<T> getEnd()
ChronoIntervalYields the upper bound of this interval.
getEnd in interface ChronoInterval<T extends Temporal<? super T>>public final <R> R get(ChronoFunction<ChronoInterval<T>,R> function)
Lets given query evaluate this interval.
R - generic type of result of queryfunction - interval querynull if undefinedChronoException - if the given query is not executableHolidayModel.firstBusinessDay(),
HolidayModel.lastBusinessDay()public I withStart(T temporal)
Yields a copy of this interval with given start time.
temporal - new start timepointIllegalArgumentException - if new start is after endpublic I withEnd(T temporal)
Yields a copy of this interval with given end time.
temporal - new end timepointIllegalArgumentException - if new end is before startpublic I withStart(UnaryOperator<T> operator)
Yields a copy of this interval with given operator applied on start time.
operator - operator to be applied on the startIllegalStateException - if the start boundary is infiniteIllegalArgumentException - if new start is after endwithEnd(UnaryOperator)public I withEnd(UnaryOperator<T> operator)
Yields a copy of this interval with given operator applied on end time.
Example:
PlainDate start = PlainDate.of(2014, 2, 27);
PlainDate end = PlainDate.of(2014, 5, 20);
DateInterval interval = DateInterval.between(start, end).withEnd(PlainDate.DAY_OF_MONTH.maximized());
System.out.println(interval); // [2014-02-27/2014-05-31]
operator - operator to be applied on the endIllegalStateException - if the end boundary is infiniteIllegalArgumentException - if new end is before startwithStart(UnaryOperator)public I withOpenStart()
Excludes the lower boundary from this interval.
public I withClosedStart()
Includes the lower boundary of this interval.
IllegalStateException - if the start is infinite pastpublic I withOpenEnd()
Excludes the upper boundary from this interval.
public I withClosedEnd()
Includes the upper boundary of this interval.
IllegalStateException - if the end is infinite futurepublic boolean isEmpty()
ChronoIntervalDetermines if this interval is empty.
isEmpty in interface ChronoInterval<T extends Temporal<? super T>>true if this interval does not contain any time point else falsepublic boolean isBefore(T temporal)
ChronoIntervalIs this interval before the given time point?
isBefore in interface ChronoInterval<T extends Temporal<? super T>>temporal - reference time pointtrue if this interval is before given time point else falsepublic boolean isBefore(ChronoInterval<T> other)
Is this interval before the other one?
Equivalent to the expression (precedes(other) || meets(other)).
isBefore in interface ChronoInterval<T extends Temporal<? super T>>other - another interval whose relation to this interval is to be investigatedtrue if this interval is before the other one else falsepublic boolean isAfter(T temporal)
ChronoIntervalIs this interval after the given time point?
isAfter in interface ChronoInterval<T extends Temporal<? super T>>temporal - reference time pointtrue if this interval is after given time point else falsepublic boolean isAfter(ChronoInterval<T> other)
Is this interval after the other one?
Equivalent to the expression (precededBy(other) || metBy(other)).
isAfter in interface ChronoInterval<T extends Temporal<? super T>>other - another interval whose relation to this interval is to be investigatedtrue if this interval is after the other one else falsepublic boolean contains(T temporal)
ChronoIntervalQueries if given time point belongs to this interval.
contains in interface ChronoInterval<T extends Temporal<? super T>>temporal - time point to be queriedtrue if given time point belongs to this interval else falsepublic boolean contains(ChronoInterval<T> other)
Does this interval contain the other one?
In contrast to encloses(I) the interval boundaries may also be equal.
contains in interface ChronoInterval<T extends Temporal<? super 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 I collapse()
Changes this interval to an empty interval with the same start anchor.
IllegalStateException - if the start is infinitepublic I toCanonical()
Changes this interval to an interval such that calendrical intervals become closed intervals and other intervals become half-open.
The temporal space will not be changed. Infinite boundaries also remain unchanged.
IllegalStateException - if there is no canonical form (for example for [00:00/24:00])public final boolean equals(Object obj)
Compares the boundaries (start and end) and also the time axis of this and the other interval.
Note: Two intervals which are equivalentTo(I) to each other
are not always equal to each other. For example a half-open date interval
whose end is one day later than the end of a closed date interval with
same start is considered equivalent, but not equal.
public final String toString()
Yields a descriptive string using the standard output
of the method toString() of start and end.
public String print(ChronoPrinter<T> printer)
Prints the canonical form of 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. Note: Starting with version v2.0 and before v3.9/4.6,
this method had a different behaviour and just delegated to
print(printer, BracketPolicy.SHOW_WHEN_NON_STANDARD).
printer - format object for printing start and endIllegalStateException - if the canonicalization of this interval failsIllegalArgumentException - if an interval boundary is not formattabletoCanonical(),
print(ChronoPrinter, String),
FormatPatternProvider.getIntervalPattern(Locale)public String print(ChronoPrinter<T> printer, String intervalPattern)
Prints the canonical form of this interval in a custom format.
Example:
DateInterval interval = DateInterval.since(PlainDate.of(2015, 1, 1));
ChronoFormatter<PlainDate> formatter =
ChronoFormatter.ofDatePattern("MMM d, uuuu", PatternType.CLDR, Locale.US);
System.out.println(interval.print(formatter, "since {0}"));
// output: since Jan 1, 2015
printer - format object for printing start and end componentsintervalPattern - interval pattern containing placeholders {0} and {1} (for start and end)IllegalStateException - if the canonicalization of this interval failsIllegalArgumentException - if an interval boundary is not formattabletoCanonical()public String print(ChronoPrinter<T> printer, BracketPolicy policy)
Prints the start and end separated by a slash using given formatter (technical format).
Note: Infinite boundaries are printed either as "-∞"
or "+∞". If given bracket policy is specified as SHOW_NEVER
then the canonical form of this interval will be printed. Example for an ISO-like representation:
DateInterval interval = DateInterval.since(PlainDate.of(2015, 1, 1));
System.out.println(
interval.print(
Iso8601Format.BASIC_CALENDAR_DATE,
BracketPolicy.SHOW_ALWAYS));
// output: [20150101/+∞)
printer - format object for printing start and endpolicy - strategy for printing interval boundariesIllegalStateException - if the canonicalization of this interval failsIllegalArgumentException - if an interval boundary is not formattable@Deprecated public void print(ChronoPrinter<T> startFormat, char separator, ChronoPrinter<T> endFormat, BracketPolicy policy, Appendable buffer) throws IOException
Prints this interval in a technical format using given formatters and separator.
Note: Infinite boundaries are printed either as "-∞" or "+∞".
If given bracket policy is specified as SHOW_NEVER then the canonical form of this
interval will be printed.
startFormat - format object for printing start componentseparator - char separating start and end componentendFormat - format object for printing end componentpolicy - strategy for printing interval boundariesbuffer - writing bufferIllegalStateException - if the canonicalization of this interval failsIllegalArgumentException - if an interval boundary is not formattableIOException - if writing to the buffer failspublic void print(ChronoPrinter<T> startFormat, char separator, ChronoPrinter<T> endFormat, BracketPolicy policy, InfinityStyle infinityStyle, Appendable buffer) throws IOException
Prints this interval in a technical format using given formatters and separator.
Note: If given bracket policy is specified as SHOW_NEVER then the canonical form of this
interval will be printed.
startFormat - format object for printing start componentseparator - char separating start and end componentendFormat - format object for printing end componentpolicy - strategy for printing interval boundariesinfinityStyle - style to be used for printing infinite interval boundariesbuffer - writing bufferIllegalStateException - if the canonicalization of this interval fails
or given infinity style prevents printing infinite intervalsIllegalArgumentException - if an interval boundary is not formattableIOException - if writing to the buffer failspublic boolean equivalentTo(I other)
ALLEN-relation: Does this interval equal the other one taking into account the open or closed state of the boundaries?
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval is temporally equivalent to
the other one else falsepublic boolean precedes(I other)
ALLEN-relation: Does this interval precede the other one such that there is a gap between?
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval is before the other such
that there is a gap between else falseprecededBy(IsoInterval)public boolean precededBy(I other)
ALLEN-relation: Equivalent to other.precedes(this).
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval is after the other such
that there is a gap between else falseprecedes(IsoInterval)public boolean meets(I other)
ALLEN-relation: Does this interval precede the other one such that there is no gap between?
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval is before the other such
that there is no gap between else falsemetBy(IsoInterval)public boolean metBy(I other)
ALLEN-relation: Equivalent to other.meets(this).
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval is after the other such
that there is no gap between else falsemeets(IsoInterval)public boolean overlaps(I other)
ALLEN-relation: Does this interval overlaps the other one such that the start of this interval is still before the start of the other one?
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval overlaps the other such
that the start of this interval is still before the start
of the other one else falseoverlappedBy(IsoInterval),
intersects(ChronoInterval)public boolean overlappedBy(I other)
ALLEN-relation: Equivalent to other.overlaps(this).
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if the other interval overlaps this such
that the start of the other one is still before the start
of this interval else falseoverlaps(IsoInterval),
intersects(ChronoInterval)public boolean finishes(I other)
ALLEN-relation: Does this interval finish the other one such that both end time points are equal and the start of this interval is after the start of the other one?
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval has the same end point as
the other one and a later start else falsefinishedBy(IsoInterval)public boolean finishedBy(I other)
ALLEN-relation: Equivalent to other.finishes(this).
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval has the same end point as
the other one and an earlier start else falsefinishes(IsoInterval)public boolean starts(I other)
ALLEN-relation: Does this interval start the other one such that both start time points are equal and the end of this interval is before the end of the other one?
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval has the same start point as
the other one and an earlier end else falsestartedBy(IsoInterval)public boolean startedBy(I other)
ALLEN-relation: Equivalent to other.starts(this).
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval has the same start point as
the other one and a later end else falsestarts(IsoInterval)public boolean encloses(I other)
ALLEN-relation: Does this interval enclose the other one such that this start is before the start of the other one and this end is after the end of the other one?
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval has the earlier start point and
later end compared to the other one else falseenclosedBy(IsoInterval)public boolean enclosedBy(I other)
ALLEN-relation: Equivalent to other.encloses(this).
Relation diagram:

other - another interval whose relation to this interval
is to be investigatedtrue if this interval has the later start point and
earlier end compared to the other one else falseencloses(IsoInterval)public boolean intersects(ChronoInterval<T> other)
Queries if this interval intersects the other one such that there is at least one common time point.
intersects in interface ChronoInterval<T extends Temporal<? super T>>other - another interval which might have an intersection with this intervaltrue if there is an non-empty intersection of this interval and the other one else falsefindIntersection(ChronoInterval),
overlaps(IsoInterval),
isBefore(ChronoInterval),
isAfter(ChronoInterval)public Optional<I> findIntersection(ChronoInterval<T> other)
Obtains the intersection of this interval and other one if present.
other - another interval which might have an intersection with this intervalOptional.isPresent(),
intersects(ChronoInterval)public boolean abuts(ChronoInterval<T> other)
Queries if this interval abuts the other one such that there is neither any overlap nor any gap between.
Equivalent to the expression this.meets(other) || this.metBy(other). Empty intervals never abut.
abuts in interface ChronoInterval<T extends Temporal<? super T>>other - another interval which might abut this intervaltrue if there is no intersection and no gap between else falsemeets(IsoInterval),
metBy(IsoInterval)public <V> ValueInterval<T,I,V> withValue(V value)
Creates a combination of this interval with an associated value.
V - generic value typevalue - associated value, not nullCopyright © 2014–2018. All rights reserved.