Interface LocalDayPlan


public interface LocalDayPlan
Timezone and day based view on timeline. This is the classic view on a day plan or calendar in which entries are added and viewed in local time. A LocalDayPlan has two local time boundaries for allowed times, start time and end time, which default to 0:00 (inclusive) and 24:00 exclusive. The implementer should implement a toString that shows all appointments based on local time. It is left to the discretion of the implementer to also show the gaps.
  • Method Details

    • day

      LocalDay day()
      LocalDay specifies date and time zone.
      Returns:
      the day
    • startOfDay

      Instant startOfDay()
      Start time of the day, inclusive.
      Returns:
      instant representing the start of the day
    • endOfDay

      Instant endOfDay()
      End time of the day, exclusive. E.g. when end time is 17.30, in that minute no new appointment (of 1 minute) can be added.
      Returns:
      instant representing the end of the day
    • startTime

      default LocalTime startTime()
      Get the allowed first time for this day.
      Returns:
      the start time of this plan
    • endTime

      default LocalTime endTime()
      Get the allowed latest time for this day.
      Returns:
      the end time in this plan
    • addAppointment

      Optional<Appointment> addAppointment(AppointmentData appointmentData, LocalTime start, TimePreference fallback)
      Add an appointment with start time and fallback time preference.
      Parameters:
      appointmentData - the appointment data
      start - if not null, preferred start time
      fallback - if start cannot be met, use as preference for fallback
      Returns:
      an optional of Appointment, which is present when the appointment was created successfully, or empty when not successful.
    • addAppointment

      Optional<Appointment> addAppointment(AppointmentData appointmentData, LocalTime startTime)
      Add and appointment with fix start time. This request can fail (Optional is not present) if the start time is not available.
      Parameters:
      appointmentData - data
      startTime - fixed time
      Returns:
      Optional Appointment
    • addAppointment

      Optional<Appointment> addAppointment(AppointmentData appointmentData, TimePreference preference)
      Add and appointment with time preference. This request can fail (Optional is not present) if the data's duration does not fit in the (already planned day). This method only supports TimePreferences EARLIEST or LATEST; Other values are defaulted to EARLIEST
      Parameters:
      appointmentData - data
      preference - time preference
      Returns:
      Optional Appointment
    • removeAppointment

      AppointmentRequest removeAppointment(Appointment appointment)
      Removes the given appointment, returning the AppointmentRequest of that appointment, if found. This day is searched for a non-free time slot matching the appointment. The returned data could be used to re-plan the appointment.
      Parameters:
      appointment - to remove
      Returns:
      the AppointmentRequest of the removed appointment or null if the appointment is not found.
    • removeAppointments

      List<AppointmentRequest> removeAppointments(Predicate<Appointment> filter)
      Removes appointments with description that matches a filter.
      Parameters:
      filter - to determine which items to remove.
      Returns:
      the list of AppointmentRequests of removed appointments.
    • appointments

      List<Appointment> appointments()
      Finds all appointments for this plan.
      Returns:
      list of all appointments.
    • findMatchingFreeSlotsOfDuration

      List<TimeSlot> findMatchingFreeSlotsOfDuration(Duration duration, List<LocalDayPlan> plans)
      Find matching free time slots in this and other TimeLines. To facilitate appointment proposals.
      Parameters:
      duration - Minimum duration of the slot to search for.
      plans - that could have common gaps
      Returns:
      the list of gaps this and each of the other plans have in common with a minimum length of duration.
    • findGapsFitting

      List<TimeSlot> findGapsFitting(Duration duration)
      This method finds all time gaps that can accommodate an appointment of the given duration in natural order.
      Parameters:
      duration - the requested duration for an appointment
      Returns:
      a list of gaps in which the appointment can be scheduled.
      Throws:
      IllegalArgumentException - if duration is null or negative.
    • findAppointments

      List<Appointment> findAppointments(Predicate<Appointment> filter)
      Finds all appointments matching given filter.
      Parameters:
      filter - to determine which items to select.
      Returns:
      list of matching appointments.
    • toString

      String toString()
      Return a string containing the local date, the time zone and all appointments in natural order, presented with time as local time.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the local day plan.
    • contains

      boolean contains(Appointment appointment)
      Check if day contains the given appointment.
      Parameters:
      appointment - to search for.
      Returns:
      true if the Appointment is part of the planning, false otherwise.
    • date

      default LocalDate date()
      What is the (start) date of this plan.
      Returns:
      the date according to this LocalDayPlan's time zone
    • nrOfAppointments

      int nrOfAppointments()
      Returns the number of appointments on a day.
      Returns:
      Number of appointments on this plan.
    • at

      default Instant at(int hour, int minute)
      Get the instant at the given hour and minute of this local day plan.
      Parameters:
      hour - sic
      minute - sic
      Returns:
      the point in time as Instant