Class RecurrenceRuleIterator
- All Implemented Interfaces:
Iterator<org.dmfs.rfc5545.DateTime>,InstanceIterator
Note: Some rules may recur forever, so be sure to add some limitation to your code that stops iterating after a certain number of instances or at a certain date.
-
Method Summary
Modifier and TypeMethodDescriptionvoidfastForward(long until) Skip all instances up to a specific date.voidfastForward(@NonNull org.dmfs.rfc5545.DateTime until) Skip all instances up to a specific date.booleanhasNext()org.dmfs.rfc5545.DateTimenext()org.dmfs.rfc5545.DateTimeGet the next instance.longGet the next instance.org.dmfs.rfc5545.DateTimePeek at the next instance to be returned bynextDateTime()without actually iterating it.longPeek at the next instance to be returned bynextMillis()without actually iterating it.voidskip(int skip) Skip the given number of instances.voidSkips all instances except for the last one.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Method Details
-
nextMillis
public long nextMillis()Get the next instance. The instances are guaranteed to be strictly increasing in time.- Returns:
- A time stamp of the next instance.
-
nextDateTime
public org.dmfs.rfc5545.DateTime nextDateTime()Get the next instance. The instances are guaranteed to be strictly increasing in time.- Returns:
- A
DateTimeobject for the next instance.
-
hasNext
public boolean hasNext() -
next
public org.dmfs.rfc5545.DateTime next() -
peekMillis
public long peekMillis()Peek at the next instance to be returned bynextMillis()without actually iterating it. Calling this method (even multiple times) won't affect the instances returned bynextMillis().- Returns:
- the upcoming instance or
nullif there are no more instances.
-
peekDateTime
public org.dmfs.rfc5545.DateTime peekDateTime()Peek at the next instance to be returned bynextDateTime()without actually iterating it. Calling this method (even multiple times) won't affect the instances returned bynextDateTime().- Returns:
- the upcoming instance or
nullif there are no more instances.
-
skip
public void skip(int skip) Skip the given number of instances.Note: After calling this method you should call
hasNext()before you continue because there might be less thanskipinstances left when you call this.- Parameters:
skip- The number of instances to skip.
-
fastForward
public void fastForward(long until) Skip all instances up to a specific date.Note: After calling this method you should call
hasNext()before you continue because there might no more instances left if there is an UNTIL or COUNT part in the rule.- Parameters:
until- The time stamp of earliest date to be returned by the next call tonextMillis()ornextDateTime().
-
fastForward
public void fastForward(@NonNull org.dmfs.rfc5545.DateTime until) Skip all instances up to a specific date.Note: After calling this method you should call
hasNext()before you continue because there might no more instances left if there is an UNTIL or COUNT part in the rule.- Specified by:
fastForwardin interfaceInstanceIterator- Parameters:
until- The earliest date to be returned by the next call tonextMillis()ornextDateTime().
-
skipAllButLast
public void skipAllButLast()Skips all instances except for the last one. Ensure to callhasNext()before callingnextMillis()ornextDateTime()after you called this.Note: At present this will loop infinitely when called on an infinite rule. So better check
RecurrenceRule.isInfinite()first.
-