Class IntervalCollection<T>
- Type Parameters:
 T- generic type characterizing the associated time axis
- All Implemented Interfaces:
 Serializable,Iterable<ChronoInterval<T>>,Collection<ChronoInterval<T>>
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. 
- Since:
 - 2.0
 - Author:
 - Meno Hochschild
 - See Also:
 DateInterval.comparator(),ClockInterval.comparator(),TimestampInterval.comparator(),MomentInterval.comparator()
- 
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(ChronoInterval<T> interval)Queries if given interval is stored in this collection.booleanQueries if any interval of this collection contains given temporal.booleanReturns all appended intervals.Returns the overall maximum of this interval collection.Returns the overall minimum of this interval collection.getRange()Yields the full min-max-range of this instance.inthashCode()intersect(IntervalCollection<T> other)Determines the intersection.booleanQueries if there is no intersection of intervals.booleanisEmpty()Gives an answer if this instance contains no intervals.iterator()Obtains an interval iterator.minus(Collection<? extends ChronoInterval<T>> intervals)Subtracts all timepoints of given intervals from this interval collection.minus(ChronoInterval<T> interval)Subtracts all timepoints of given interval from this interval collection.minus(IntervalCollection<T> other)Equivalent tominus(other.getIntervals()).static <T> IntervalCollection<T>Yields an empty instance for intervals on given timeline.static IntervalCollection<PlainTime>Yields an empty instance on the walltime axis.static IntervalCollection<PlainDate>Yields an empty instance on the date axis.static IntervalCollection<Instant>Yields an empty instance for intervals with the component typejava.time.Instant.static IntervalCollection<Moment>Yields an empty instance on the UTC-axis.static IntervalCollection<PlainTimestamp>Yields an empty instance on the timestamp axis.static IntervalCollection<Date>Yields an empty instance for intervals with the component typejava.util.Date.plus(Collection<? extends ChronoInterval<T>> intervals)Adds the given intervals to this interval collection.plus(ChronoInterval<T> interval)Adds the given interval to this interval collection.plus(IntervalCollection<T> other)Equivalent toplus(other.getIntervals()).intsize()Obtains the count of stored intervals.toString()For debugging purposes.union(IntervalCollection<T> other)Equivalent toplus(other).withBlocks().Combines all intervals to disjunct blocks which neither overlap nor meet each other.withComplement(ChronoInterval<T> timeWindow)Determines the complement of this interval collection within given range.withGaps()Searches for all gaps with time points which are not covered by any interval of this instance.Determines the intersection of all contained intervals.Combines all intervals to disjunct blocks which never overlap but still might meet each other.withTimeWindow(ChronoInterval<T> timeWindow)Determines a filtered version of this interval collection within given range.xor(IntervalCollection<T> other)Determines the difference which holds all time points either in this xor the other collection.Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, remove, removeAll, retainAll, toArray, toArrayMethods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray 
- 
Method Details
- 
onDateAxis
Yields an empty instance on the date axis.
- Returns:
 - empty 
IntervalCollectionfor date intervals - Since:
 - 2.0
 
 - 
onClockAxis
Yields an empty instance on the walltime axis.
- Returns:
 - empty 
IntervalCollectionfor clock intervals - Since:
 - 2.0
 
 - 
onTimestampAxis
Yields an empty instance on the timestamp axis.
- Returns:
 - empty 
IntervalCollectionfor timestamp intervals - Since:
 - 2.0
 
 - 
onMomentAxis
Yields an empty instance on the UTC-axis.
- Returns:
 - empty 
IntervalCollectionfor moment intervals - Since:
 - 2.0
 
 - 
onTraditionalTimeLine
Yields an empty instance for intervals with the component type
java.util.Date.- Returns:
 - empty 
IntervalCollectionfor oldjava.util.Date-intervals - Since:
 - 3.25/4.21
 
 - 
onInstantTimeLine
Yields an empty instance for intervals with the component type
java.time.Instant.- Returns:
 - empty 
IntervalCollectionforjava.time.Instant-intervals - Since:
 - 4.21
 
 - 
on
Yields an empty instance for intervals on given timeline.
- Type Parameters:
 T- generic type of time points- Parameters:
 timeLine- the associated timeline- Returns:
 - empty generic 
IntervalCollection - Since:
 - 5.0
 - See Also:
 TimeAxis,CalendarFamily.getTimeLine(String),CalendarFamily.getTimeLine(net.time4j.engine.VariantSource),CalendarYear.timeline(),CalendarQuarter.timeline(),CalendarMonth.timeline(),CalendarWeek.timeline()
 - 
getIntervals
Returns all appended intervals.
Note that all contained finite intervals have each a closed start.
- Returns:
 - unmodifiable list of intervals sorted by start and then by length
 - Since:
 - 2.0
 
 - 
iterator
Obtains an interval iterator.
- Specified by:
 iteratorin interfaceCollection<T>- Specified by:
 iteratorin interfaceIterable<T>- Specified by:
 iteratorin classAbstractCollection<ChronoInterval<T>>- Returns:
 - Iterator
 - Since:
 - 3.35/4.30
 
 - 
size
public int size()Obtains the count of stored intervals.
- Specified by:
 sizein interfaceCollection<T>- Specified by:
 sizein classAbstractCollection<ChronoInterval<T>>- Returns:
 - int
 - Since:
 - 3.35/4.30
 
 - 
isEmpty
public boolean isEmpty()Gives an answer if this instance contains no intervals.
- Specified by:
 isEmptyin interfaceCollection<T>- Overrides:
 isEmptyin classAbstractCollection<ChronoInterval<T>>- Returns:
 trueif there are no intervals elsefalse- Since:
 - 2.0
 
 - 
isDisjunct
public boolean isDisjunct()Queries if there is no intersection of intervals.
- Returns:
 trueif there is no intersection elsefalse- Since:
 - 3.24/4.20
 
 - 
encloses
Queries if any interval of this collection contains given temporal.
- Parameters:
 temporal- time point to be queried- Returns:
 trueif given time point belongs to any interval of this collection elsefalse- Since:
 - 3.35/4.30
 
 - 
contains
Queries if given interval is stored in this collection.
- Parameters:
 interval- the interval to be checked- Returns:
 - boolean
 - Since:
 - 3.35/4.30
 
 - 
getMinimum
Returns the overall minimum of this interval collection.
The minimum is always inclusive, if finite.
- Returns:
 - lower limit of this instance or 
nullif infinite - Throws:
 NoSuchElementException- if there are no intervals- Since:
 - 2.0
 - See Also:
 isEmpty()
 - 
getMaximum
Returns the overall maximum of this interval collection.
The maximum is always inclusive, if finite.
- Returns:
 - upper limit of this instance or 
nullif infinite - Throws:
 NoSuchElementException- if there are no intervals- Since:
 - 2.0
 - See Also:
 isEmpty()
 - 
getRange
Yields the full min-max-range of this instance.
- Returns:
 - minimum range interval spanning over all enclosed intervals
 - Since:
 - 3.7/4.5
 
 - 
plus
Adds the given interval to this interval collection.
An empty interval will be ignored.
- Parameters:
 interval- the new interval to be added- Returns:
 - new IntervalCollection-instance containing a sum of the own intervals and the given one while this instance remains unaffected
 - Throws:
 IllegalArgumentException- if given interval is finite and has open start which cannot be adjusted to one with closed start- Since:
 - 2.0
 
 - 
plus
Adds the given intervals to this interval collection.
Empty intervals will be ignored.
- Parameters:
 intervals- the new intervals to be added- Returns:
 - new IntervalCollection-instance containing a sum of the own intervals and the given one while this instance remains unaffected
 - Throws:
 IllegalArgumentException- if given list contains a finite interval with open start which cannot be adjusted to one with closed start- Since:
 - 3.35/4.30
 
 - 
plus
Equivalent to
plus(other.getIntervals()).- Parameters:
 other- another interval collection whose intervals are to be added to this instance- Returns:
 - new interval collection containing the intervals of this instance and the argument
 - Throws:
 IllegalArgumentException- if given collection contains a finite interval with open start which cannot be adjusted to one with closed start- Since:
 - 3.7/4.5
 
 - 
minus
Subtracts all timepoints of given interval from this interval collection.
- Parameters:
 interval- other interval to be subtracted from this- Returns:
 - new interval collection containing all timepoints of this instance excluding those of given interval
 - Throws:
 IllegalArgumentException- if given interval is finite and has open start which cannot be adjusted to one with closed start- Since:
 - 2.2
 
 - 
minus
Subtracts all timepoints of given intervals from this interval collection.
- Parameters:
 intervals- collection of intervals to be subtracted- Returns:
 - new interval collection containing all timepoints of this instance excluding those of given intervals
 - Throws:
 IllegalArgumentException- if given list contains a finite interval with open start which cannot be adjusted to one with closed start- Since:
 - 3.35/4.30
 
 - 
minus
Equivalent to
minus(other.getIntervals()).- Parameters:
 other- another interval collection whose intervals are to be subtracted from this instance- Returns:
 - new interval collection containing all timepoints of this instance excluding those of argument
 - Throws:
 IllegalArgumentException- if given collection contains a finite interval with open start which cannot be adjusted to one with closed start- Since:
 - 3.7/4.5
 
 - 
withTimeWindow
Determines a filtered version of this interval collection within given range.
- Parameters:
 timeWindow- time window filter- Returns:
 - new interval collection containing only timepoints within given range
 - Throws:
 IllegalArgumentException- if given window is finite and has open start which cannot be adjusted to one with closed start- Since:
 - 2.1
 
 - 
withComplement
Determines the complement of this interval collection within given range.
- Parameters:
 timeWindow- time window filter- Returns:
 - new interval collection containing all timepoints within given range which do not belong to this instance
 - Throws:
 IllegalArgumentException- if given window is finite and has open start which cannot be adjusted to one with closed start- Since:
 - 2.1
 
 - 
withGaps
Searches for all gaps with time points which are not covered by any interval of this instance.

- Returns:
 - new interval collection containing the inner gaps between the own intervals while this instance remains unaffected
 - Since:
 - 2.0
 
 - 
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.
- Returns:
 - new interval collection containing disjunct merged blocks while this instance remains unaffected
 - Since:
 - 2.0
 
 - 
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.
- Returns:
 - new interval collection containing disjunct splitted sections while this instance remains unaffected
 - Since:
 - 3.24/4.20
 
 - 
withIntersection
Determines the intersection of all contained intervals.
Note: This instance remains unaffected as specified for immutable classes.

- Returns:
 - new interval collection containing the intersection interval, maybe empty (if there is no intersection)
 - Since:
 - 2.0
 
 - 
union
Equivalent to
plus(other).withBlocks().Note: Before version 3.7/4.5 the behaviour was just giving an unmerged collection.
- Parameters:
 other- another interval collection whose intervals are to be added to this instance- Returns:
 - new merged interval collection with disjunct blocks
 - Since:
 - 2.0
 
 - 
intersect
Determines the intersection.
- Parameters:
 other- another interval collection- Returns:
 - new interval collection with disjunct blocks containing all time points in both interval collections
 - Since:
 - 3.8/4.5
 
 - 
xor
Determines the difference which holds all time points either in this xor the other collection.
- Parameters:
 other- another interval collection- Returns:
 - new interval collection with disjunct blocks containing all time points which are in only one of both interval collections
 - Since:
 - 3.8/4.5
 
 - 
equals
- Specified by:
 equalsin interfaceCollection<T>- Overrides:
 equalsin classObject
 - 
hashCode
public int hashCode()- Specified by:
 hashCodein interfaceCollection<T>- Overrides:
 hashCodein classObject
 - 
toString
For debugging purposes.
- Overrides:
 toStringin classAbstractCollection<ChronoInterval<T>>- Returns:
 - String
 
 
 -