Class Recurrence

    • Field Detail

      • NO_RECURRENCE

        public static final Recurrence NO_RECURRENCE
        A constant that defines a specific value for an empty recurrence.
      • NO_RECURRENCE_COUNT

        public static final int NO_RECURRENCE_COUNT
        A constant that defines a specific value for no recurrence count limit.
        See Also:
        Constant Field Values
      • NO_RECURRENCE_END_DATE

        public static final OffsetDateTime NO_RECURRENCE_END_DATE
        A constant that defines a specific value for no recurrence end date.
    • Constructor Detail

      • Recurrence

        protected Recurrence()
        Constructs an empty recurrence for the persistence engine.
    • Method Detail

      • every

        public static Recurrence every​(TimeUnit frequencyUnit)
        Creates a new recurrence from the specified frequency.
        Parameters:
        frequencyUnit - the unit of the frequency: DAY means DAILY, WEEK means weekly, MONTH means monthly or YEAR means YEARLY.
        Returns:
        the event recurrence instance.
      • every

        public static Recurrence every​(int frequencyValue,
                                       TimeUnit frequencyUnit)
        Creates a new recurrence from the specified frequency. For example every(2, MONTH) means every 2 month.
        Parameters:
        frequencyValue - a positive number indicating how many times the PlannableOnCalendar occurs.
        frequencyUnit - the frequency unit: DAY, WEEK, MONTH, or YEAR.
        Returns:
        the event recurrence instance.
      • from

        public static Recurrence from​(RecurrencePeriod period)
        Creates a new recurrence by specifying the recurrence period at which a PlannableOnCalendar should recur.
        Parameters:
        period - the recurrence period of the event.
        Returns:
        the event recurrence instance.
      • excludeEventOccurrencesStartingAt

        public Recurrence excludeEventOccurrencesStartingAt​(Temporal... temporal)
        Excludes from this recurrence rule the occurrences originally starting at the specified date or datetime. In the case the argument is one or more OffsetDateTime, their time is set with the time of the start datetime of the calendar component concerned by this recurrence. If the calendar component from which the occurrences come is on all day, the specified temporal instance is then converted into a LocalDate instance. Otherwise, if the the temporal instance is a LocalDate it is then converted into a OffsetDateTime with the time the one of the calendar component's start datetime; you have to ensure then the LocalDate you pass comes from a value in UTC. If the temporal instance is already an OffsetDateTime, then it is converted in UTC and its time set with the one of the calendar component's start datetime.
        Parameters:
        temporal - a list of either LocalDate or OffsetDateTime at which originally start the occurrences to exclude.
        Returns:
        itself.
      • on

        public Recurrence on​(DayOfWeek... days)
        Sets some specific days of week at which a PlannableOnCalendar should periodically occur. For a weekly recurrence, the specified days of week are the first one in the week. For other frequency, the specified days of week will be all the occurrences of those days of week in the recurrence period. For example, recur every weeks on monday and on tuesday or recur every month on all saturdays and on all tuesdays. This method can only be applied on recurrence period higher than the day, otherwise an IllegalStateException will be thrown.
        Parameters:
        days - the days of week at which a PlannableOnCalendar should occur. Theses days replace the ones already set in the recurrence.
        Returns:
        itself.
      • on

        public Recurrence on​(DayOfWeekOccurrence... days)
        Sets some specific occurrences of day of week at which a PlannableOnCalendar should periodically occur within a monthly or a yearly period. For example, recur every month on the third monday and on the first tuesday. The days of week for a weekly recurrence can also be indicated if, and only if, the nth occurrence of the day is the first one or all occurrences (as there is actually only one possible occurrence of a day in a week); any value other than 1 or ALL_OCCURRENCES is considered as an error and an IllegalArgumentException is thrown. This method can only be applied on recurrence period higher than the day, otherwise an IllegalStateException will be thrown.
        Parameters:
        days - the occurrences of day of week at which an event should occur. Theses days replace the ones already set in the recurrence.
        Returns:
        itself.
      • on

        public Recurrence on​(List<DayOfWeekOccurrence> days)
        Sets some specific occurrences of day of week at which a PlannableOnCalendar should periodically occur within monthly or yearly period. For example, recur every month on the third monday and on the first tuesday. The days of week for a weekly recurrence can also be indicated if, and only if, the nth occurrence of the day is the first one or all occurrences (as there is actually only one possible occurrence of a day in a week); any value other than 1 or ALL_OCCURRENCES is considered as an error and an IllegalArgumentException is thrown. This method can only be applied on recurrence period higher than the day, otherwise an IllegalStateException will be thrown.
        Parameters:
        days - a list of days of week at which a PlannableOnCalendar should occur. Theses days replace the ones already set in the recurrence.
        Returns:
        itself.
      • onNoSpecificDay

        public Recurrence onNoSpecificDay()
        Sets that the recurrence is not linked to a specific day. So the occurrence generation will take into account only the start datetime of the event.
        Returns:
        itself.
      • until

        public Recurrence until​(int recurrenceCount)
        Sets a termination to this recurrence by specifying the count of time a PlannableOnCalendar should occur. Settings this termination unset the recurrence end date/datetime.
        Parameters:
        recurrenceCount - the number of time a PlannableOnCalendar should occur.
        Returns:
        itself.
      • until

        public Recurrence until​(Temporal endDate)
        Sets a termination to this recurrence by specifying an inclusive date or datetime. If a datetime is passed, it is set in UTC/Greenwich and then the time is overridden by the one of the start date time of the calendar component concerned by this recurrence. In the case the calendar component is on all day(s), then the specified datetime is converted into a date. Settings this termination unset the number of time a PlannableOnCalendar should occur.
        Parameters:
        endDate - the inclusive date or datetime at which the recurrence ends.
        Returns:
        itself.
      • endless

        public Recurrence endless()
        Sets that the recurrence never ends.
        Returns:
        itself.
      • withFrequency

        public Recurrence withFrequency​(RecurrencePeriod frequency)
        Sets a frequency to this recurrence by specifying a recurrence period.
        When the new frequency is a daily or a yearly one, days of weeks are reset.
        Parameters:
        frequency - the frequency to set.
        Returns:
        itself.
      • isEndless

        public boolean isEndless()
        Is this recurrence endless?
        Returns:
        true if this recurrence has no upper bound defined. False otherwise.
      • getFrequency

        public RecurrencePeriod getFrequency()
        Gets the frequency at which the PlannableOnCalendar should recur.
        Returns:
        the frequency as a RecurrencePeriod instance.
      • getRecurrenceCount

        public int getRecurrenceCount()
        Gets the number of time the PlannableOnCalendar should occur. If NO_RECURRENCE_COUNT is returned, then no termination by recurrence count is defined.
        Returns:
        the recurrence count or NO_RECURRENCE_COUNT if no such termination is defined.
      • getRecurrenceEndDate

        public Optional<Temporal> getRecurrenceEndDate()
        Gets the end date of the recurrence. The end date of the recurrence can be unspecified, in that case the returned end date is empty.
        Returns:
        an optional recurrence end date. The optional is empty if the end date of the recurrence is unspecified, otherwise the recurrence termination date or datetime can be get from the Optional. The returned datetime is from UTC/Greenwich.
      • getEndDate

        public Optional<Temporal> getEndDate()
        Gets the end date of the period over which this recurrence is played by taking into account either the number of time he recurrent PlannableOnCalendar occurs or the end date of its recurrence. The computed date can match the date of the last occurrence of the recurrent PlannableOnCalendar for a finite recurrence without an end date explicitly set. It can be also a date after the last occurrence. The exception dates in the recurrence rule aren't taken into account. If this recurrence isn't yet applied to any recurrence calendar component, then an IllegalStateException exception is thrown.
        Returns:
        an optional recurrence actual end date. The optional is empty if the recurrence is endless.
      • getStartDate

        public Temporal getStartDate()
        Gets the start date of the period over which this recurrence is played. It is the date of the first occurrence of the recurrent PlannableOnCalendar on which this recurrence is applied.

        If this recurrence isn't yet applied to any recurrence calendar component, then an IllegalStateException exception is thrown.

        Returns:
        the start date of this recurrence.
      • getDaysOfWeek

        public Set<DayOfWeekOccurrence> getDaysOfWeek()
        Gets the days of week on which the PlannableOnCalendar should recur each time.
        Returns:
        an unmodifiable set of days of week or an empty set if no days of week are set to this recurrence.
      • getExceptionDates

        public Set<Temporal> getExceptionDates()
        Gets the datetime exceptions to this recurrence rule. The returned datetime are the start datetime of the occurrences that are excluded from this recurrence rule. They are the exception in the application of the recurrence rule.
        Returns:
        a set of either LocalDate or OffsetDateTime instances, or an empty set if there is no exception dates to this recurrence.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • copy

        public Recurrence copy()
        Copies the specified recurrence into another object. The identifier of the recurrence is set to null as it is not yet persisted.
        Returns:
        a copy of this recurrence.
      • generateId

        protected void generateId()