Package net.fortuna.ical4j.model
Class PeriodList<T extends Temporal>
- java.lang.Object
-
- net.fortuna.ical4j.model.PeriodList<T>
-
- All Implemented Interfaces:
Serializable
public class PeriodList<T extends Temporal> extends Object implements Serializable
$Id$ [23-Apr-2004] Defines a list of iCalendar periods. This class encapsulates a collection of naturally sorted periods that SHOULD conform to a common set of rules, including temporal type, applicable timezone and string representation (format). Results for a consumed time query will have the same temporal type, format type and (where applicable) timezone as the event start date. Results for a free-busy query will always be defined in UTC time (i.e. using temporal typeInstant
) NOTE: By implementing thejava.util.SortedSet
interface period lists will always be sorted according to natural ordering.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PeriodList()
Default constructor.PeriodList(Collection<Period<T>> periods)
PeriodList(Collection<Period<T>> periods, CalendarDateFormat dateFormat)
PeriodList(CalendarDateFormat dateFormat)
PeriodList(org.threeten.extra.Interval[] intervals)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PeriodList<T>
add(Period<T> period)
Add a period to the list.PeriodList<T>
add(PeriodList<T> periods)
A convenience method that combines all the periods in the specified list to this list.PeriodList<T>
addAll(Collection<Period<T>> arg0)
boolean
equals(Object o)
Set<Period<T>>
getPeriods()
int
hashCode()
PeriodList<T>
normalise()
Returns a normalised version of this period list.static <T extends Temporal>
PeriodList<T>parse(String aValue)
Parses the specified string representation to create a list of periods.static <T extends Temporal>
PeriodList<T>parse(String aValue, CalendarDateFormat calendarDateFormat)
PeriodList<T>
remove(Object period)
Remove a period from the list.PeriodList<T>
subtract(PeriodList<T> subtractions)
Subtracts the intersection of this list with the specified list of periods from this list and returns the results as a new period list.List<org.threeten.extra.Interval>
toIntervalList()
String
toString()
String
toString(ZoneId zoneId)
-
-
-
Constructor Detail
-
PeriodList
public PeriodList()
Default constructor.
-
PeriodList
public PeriodList(CalendarDateFormat dateFormat)
-
PeriodList
public PeriodList(Collection<Period<T>> periods)
-
PeriodList
public PeriodList(Collection<Period<T>> periods, CalendarDateFormat dateFormat)
-
PeriodList
public PeriodList(org.threeten.extra.Interval[] intervals)
-
-
Method Detail
-
parse
public static <T extends Temporal> PeriodList<T> parse(String aValue)
Parses the specified string representation to create a list of periods.- Parameters:
aValue
- a string representation of a list of periods- Throws:
DateTimeParseException
- thrown when an invalid string representation of a period list is provided
-
parse
public static <T extends Temporal> PeriodList<T> parse(String aValue, CalendarDateFormat calendarDateFormat)
-
add
public final PeriodList<T> add(Period<T> period)
Add a period to the list.- Parameters:
period
- the period to add- Returns:
- true
- See Also:
List.add(java.lang.Object)
-
remove
public final PeriodList<T> remove(Object period)
Remove a period from the list.- Parameters:
period
- the period to remove- Returns:
- true if the list contained the specified period
- See Also:
List.remove(java.lang.Object)
-
normalise
public final PeriodList<T> normalise()
Returns a normalised version of this period list. Normalisation includes combining overlapping periods, removing periods contained by other periods, combining adjacent periods, and removing periods that consume no time. NOTE: If the period list is already normalised then this period list is returned.- Returns:
- a period list
-
add
public final PeriodList<T> add(PeriodList<T> periods)
A convenience method that combines all the periods in the specified list to this list. The result returned is a new PeriodList instance, except where no periods are specified in the arguments. In such cases this instance is returned. Normalisation is also performed automatically after all periods have been added.- Parameters:
periods
- a list of periods to add- Returns:
- a period list instance
-
subtract
public final PeriodList<T> subtract(PeriodList<T> subtractions)
Subtracts the intersection of this list with the specified list of periods from this list and returns the results as a new period list. If no intersection is identified this list is returned.- Parameters:
subtractions
- a list of periods to subtract from this list- Returns:
- a period list
-
addAll
public PeriodList<T> addAll(Collection<Period<T>> arg0)
-
toIntervalList
public List<org.threeten.extra.Interval> toIntervalList()
-
-