Package com.redwood.scheduler.api.date
Class Periods
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<Period>
-
- com.redwood.scheduler.api.date.Periods
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<Period>
,Collection<Period>
,List<Period>
,RandomAccess
public class Periods extends ArrayList<Period>
ArrayList that implements set operations on Period elements.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Comparator<Period>
getNextOpenComparator()
Period
getPeriod(int aIndex)
Typesafe accessor to the element at aIndex.int
getPeriodFor(DateTimeZone date)
Find the index for the period that contains date.void
intersect(Period aPeriod)
Intersects this periods with aPeriod.void
intersect(Periods aPeriods)
Replaces the elements from this with the intersection of this periods with aPeriods.void
joinOverlappingIntervals()
Joins overlapping and continuing periods.void
subtract(Period aPeriod)
Excludes aPeriod from this periods.void
subtract(Periods aPeriods)
Excludes aPeriods from this periods.-
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
Methods inherited from class java.util.AbstractCollection
containsAll, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface java.util.List
containsAll
-
-
-
-
Constructor Detail
-
Periods
public Periods()
-
Periods
public Periods(Periods copyFrom)
-
-
Method Detail
-
getPeriod
public Period getPeriod(int aIndex)
Typesafe accessor to the element at aIndex.- Parameters:
aIndex
- point in time in a period.- Returns:
- the Period at aIndex.
-
getPeriodFor
public int getPeriodFor(DateTimeZone date)
Find the index for the period that contains date. The period is extended until the next open period.- Parameters:
date
- is the DateTimeZone to look for- Returns:
- index of the search key, if it is contained in the list
-
intersect
public void intersect(Periods aPeriods)
Replaces the elements from this with the intersection of this periods with aPeriods.- Parameters:
aPeriods
- are the periods to exclude.
-
intersect
public void intersect(Period aPeriod)
Intersects this periods with aPeriod.- Parameters:
aPeriod
- is the period to intersect with.
-
joinOverlappingIntervals
public void joinOverlappingIntervals()
Joins overlapping and continuing periods. Assumes the periods are sorted on begin time.
-
subtract
public void subtract(Periods aPeriods)
Excludes aPeriods from this periods.- Parameters:
aPeriods
- are the periods to exclude.
-
subtract
public void subtract(Period aPeriod)
Excludes aPeriod from this periods.- Parameters:
aPeriod
- is the period to exclude.
-
getNextOpenComparator
public static Comparator<Period> getNextOpenComparator()
-
-