T - generic type characterizing the associated time axispublic abstract class IntervalCollection<T> extends AbstractCollection<ChronoInterval<T>> implements Serializable
Represents a sorted list of arbitrary possibly overlapping intervals (no series) whose boundaries can be changed in many ways.
Any instance can first be achieved by calling one of the static
onXYZAxis()-methods and then be filled with any count of
typed intervals via plus(...)-methods. All intervals are
stored with closed start if they have finite start. Empty intervals
are never stored.
DateInterval.comparator(),
ClockInterval.comparator(),
TimestampInterval.comparator(),
MomentInterval.comparator()| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(ChronoInterval<T> interval)
Queries if given interval is stored in this collection.
|
boolean |
encloses(T temporal)
Queries if any interval of this collection contains given temporal.
|
boolean |
equals(Object obj) |
List<ChronoInterval<T>> |
getIntervals()
Returns all appended intervals.
|
T |
getMaximum()
Returns the overall maximum of this interval collection.
|
T |
getMinimum()
Returns the overall minimum of this interval collection.
|
ChronoInterval<T> |
getRange()
Yields the full min-max-range of this instance.
|
int |
hashCode() |
IntervalCollection<T> |
intersect(IntervalCollection<T> other)
Determines the intersection.
|
boolean |
isDisjunct()
Queries if there is no intersection of intervals.
|
boolean |
isEmpty()
Gives an answer if this instance contains no intervals.
|
Iterator<ChronoInterval<T>> |
iterator()
Obtains an interval iterator.
|
IntervalCollection<T> |
minus(ChronoInterval<T> interval)
Subtracts all timepoints of given interval from this interval collection.
|
IntervalCollection<T> |
minus(Collection<? extends ChronoInterval<T>> intervals)
Subtracts all timepoints of given intervals from this interval
collection.
|
IntervalCollection<T> |
minus(IntervalCollection<T> other)
Equivalent to
minus(other.getIntervals()). |
static <T> IntervalCollection<T> |
on(TimeLine<T> timeLine)
Yields an empty instance for intervals on given timeline.
|
static IntervalCollection<PlainTime> |
onClockAxis()
Yields an empty instance on the walltime axis.
|
static IntervalCollection<PlainDate> |
onDateAxis()
Yields an empty instance on the date axis.
|
static IntervalCollection<Instant> |
onInstantTimeLine()
Yields an empty instance for intervals with the component type
java.time.Instant. |
static IntervalCollection<Moment> |
onMomentAxis()
Yields an empty instance on the UTC-axis.
|
static IntervalCollection<PlainTimestamp> |
onTimestampAxis()
Yields an empty instance on the timestamp axis.
|
static IntervalCollection<Date> |
onTraditionalTimeLine()
Yields an empty instance for intervals with the component type
java.util.Date. |
IntervalCollection<T> |
plus(ChronoInterval<T> interval)
Adds the given interval to this interval collection.
|
IntervalCollection<T> |
plus(Collection<? extends ChronoInterval<T>> intervals)
Adds the given intervals to this interval collection.
|
IntervalCollection<T> |
plus(IntervalCollection<T> other)
Equivalent to
plus(other.getIntervals()). |
int |
size()
Obtains the count of stored intervals.
|
String |
toString()
For debugging purposes.
|
IntervalCollection<T> |
union(IntervalCollection<T> other)
Equivalent to
plus(other).withBlocks(). |
IntervalCollection<T> |
withBlocks()
Combines all intervals to disjunct blocks which neither overlap nor meet each other.
|
IntervalCollection<T> |
withComplement(ChronoInterval<T> timeWindow)
Determines the complement of this interval collection within
given range.
|
IntervalCollection<T> |
withGaps()
Searches for all gaps with time points which are not covered by any
interval of this instance.
|
IntervalCollection<T> |
withIntersection()
Determines the intersection of all contained intervals.
|
IntervalCollection<T> |
withSplits()
Combines all intervals to disjunct blocks which never overlap but still might meet each other.
|
IntervalCollection<T> |
withTimeWindow(ChronoInterval<T> timeWindow)
Determines a filtered version of this interval collection within
given range.
|
IntervalCollection<T> |
xor(IntervalCollection<T> other)
Determines the difference which holds all time points either in this xor the other collection.
|
add, addAll, clear, contains, containsAll, remove, removeAll, retainAll, toArray, toArrayparallelStream, removeIf, spliterator, streampublic static IntervalCollection<PlainDate> onDateAxis()
Yields an empty instance on the date axis.
IntervalCollection for date intervalspublic static IntervalCollection<PlainTime> onClockAxis()
Yields an empty instance on the walltime axis.
IntervalCollection for clock intervalspublic static IntervalCollection<PlainTimestamp> onTimestampAxis()
Yields an empty instance on the timestamp axis.
IntervalCollection for timestamp intervalspublic static IntervalCollection<Moment> onMomentAxis()
Yields an empty instance on the UTC-axis.
IntervalCollection for moment intervalspublic static IntervalCollection<Date> onTraditionalTimeLine()
Yields an empty instance for intervals with the component type java.util.Date.
IntervalCollection for old java.util.Date-intervalspublic static IntervalCollection<Instant> onInstantTimeLine()
Yields an empty instance for intervals with the component type java.time.Instant.
IntervalCollection for java.time.Instant-intervalspublic static <T> IntervalCollection<T> on(TimeLine<T> timeLine)
Yields an empty instance for intervals on given timeline.
IntervalCollectionTimeAxis,
CalendarFamily.getTimeLine(String),
CalendarFamily.getTimeLine(net.time4j.engine.VariantSource),
CalendarYear.timeline(),
CalendarQuarter.timeline(),
CalendarMonth.timeline(),
CalendarWeek.timeline()public List<ChronoInterval<T>> getIntervals()
Returns all appended intervals.
Note that all contained finite intervals have each a closed start.
public Iterator<ChronoInterval<T>> iterator()
Obtains an interval iterator.
iterator in interface Iterable<ChronoInterval<T>>iterator in interface Collection<ChronoInterval<T>>iterator in class AbstractCollection<ChronoInterval<T>>public int size()
Obtains the count of stored intervals.
size in interface Collection<ChronoInterval<T>>size in class AbstractCollection<ChronoInterval<T>>public boolean isEmpty()
Gives an answer if this instance contains no intervals.
isEmpty in interface Collection<ChronoInterval<T>>isEmpty in class AbstractCollection<ChronoInterval<T>>true if there are no intervals else falsepublic boolean isDisjunct()
Queries if there is no intersection of intervals.
true if there is no intersection else falsepublic boolean encloses(T temporal)
Queries if any interval of this collection contains given temporal.
temporal - time point to be queriedtrue if given time point belongs to any interval of this collection else falsepublic boolean contains(ChronoInterval<T> interval)
Queries if given interval is stored in this collection.
interval - the interval to be checkedpublic T getMinimum()
Returns the overall minimum of this interval collection.
The minimum is always inclusive, if finite.
null if infiniteNoSuchElementException - if there are no intervalsisEmpty()public T getMaximum()
Returns the overall maximum of this interval collection.
The maximum is always inclusive, if finite.
null if infiniteNoSuchElementException - if there are no intervalsisEmpty()public ChronoInterval<T> getRange()
Yields the full min-max-range of this instance.
public IntervalCollection<T> plus(ChronoInterval<T> interval)
Adds the given interval to this interval collection.
An empty interval will be ignored.
interval - the new interval to be addedIllegalArgumentException - if given interval is finite and has
open start which cannot be adjusted to one with closed startpublic IntervalCollection<T> plus(Collection<? extends ChronoInterval<T>> intervals)
Adds the given intervals to this interval collection.
Empty intervals will be ignored.
intervals - the new intervals to be addedIllegalArgumentException - if given list contains a finite
interval with open start which cannot be adjusted to one with closed startpublic IntervalCollection<T> plus(IntervalCollection<T> other)
Equivalent to plus(other.getIntervals()).
other - another interval collection whose intervals are to be added to this instanceIllegalArgumentException - if given collection contains a finite
interval with open start which cannot be adjusted to one with closed startpublic IntervalCollection<T> minus(ChronoInterval<T> interval)
Subtracts all timepoints of given interval from this interval collection.
interval - other interval to be subtracted from thisIllegalArgumentException - if given interval is finite and has
open start which cannot be adjusted to one with closed startpublic IntervalCollection<T> minus(Collection<? extends ChronoInterval<T>> intervals)
Subtracts all timepoints of given intervals from this interval collection.
intervals - collection of intervals to be subtractedIllegalArgumentException - if given list contains a finite
interval with open start which cannot be adjusted to one
with closed startpublic IntervalCollection<T> minus(IntervalCollection<T> other)
Equivalent to minus(other.getIntervals()).
other - another interval collection whose intervals are to be subtracted from this instanceIllegalArgumentException - if given collection contains a finite
interval with open start which cannot be adjusted to one with closed startpublic IntervalCollection<T> withTimeWindow(ChronoInterval<T> timeWindow)
Determines a filtered version of this interval collection within given range.
timeWindow - time window filterIllegalArgumentException - if given window is finite and has
open start which cannot be adjusted to one with closed startpublic IntervalCollection<T> withComplement(ChronoInterval<T> timeWindow)
Determines the complement of this interval collection within given range.
timeWindow - time window filterIllegalArgumentException - if given window is finite and has
open start which cannot be adjusted to one with closed startpublic IntervalCollection<T> withGaps()
Searches for all gaps with time points which are not covered by any interval of this instance.

public IntervalCollection<T> withBlocks()
Combines all intervals to disjunct blocks which neither overlap nor meet each other.
Any overlapping or abutting intervals will be merged to one block. If the interval boundaries
are still to be kept then consider withSplits() instead.

public IntervalCollection<T> withSplits()
Combines all intervals to disjunct blocks which never overlap but still might meet each other.
Similar to withBlocks() but all boundaries will be temporally conserved.

public IntervalCollection<T> withIntersection()
Determines the intersection of all contained intervals.
Note: This instance remains unaffected as specified for immutable classes.

public IntervalCollection<T> union(IntervalCollection<T> other)
Equivalent to plus(other).withBlocks().
Note: Before version 3.7/4.5 the behaviour was just giving an unmerged collection.
other - another interval collection whose intervals are to be added to this instancepublic IntervalCollection<T> intersect(IntervalCollection<T> other)
Determines the intersection.
other - another interval collectionpublic IntervalCollection<T> xor(IntervalCollection<T> other)
Determines the difference which holds all time points either in this xor the other collection.
other - another interval collectionpublic boolean equals(Object obj)
equals in interface Collection<ChronoInterval<T>>equals in class Objectpublic int hashCode()
hashCode in interface Collection<ChronoInterval<T>>hashCode in class Objectpublic String toString()
For debugging purposes.
toString in class AbstractCollection<ChronoInterval<T>>Copyright © 2014–2021. All rights reserved.