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 Summary
Modifier and TypeMethodDescriptionaddAppointment
(AppointmentData appointmentData, TimePreference preference) Add and appointment with time preference.addAppointment
(AppointmentData appointmentData, LocalTime startTime) Add and appointment with fix start time.addAppointment
(AppointmentData appointmentData, LocalTime start, TimePreference fallback) Add an appointment with start time and fallback time preference.Finds all appointments for this plan.default Instant
at
(int hour, int minute) Get the instant at the given hour and minute of this local day plan.boolean
contains
(Appointment appointment) Check if day contains the given appointment.default LocalDate
date()
What is the (start) date of this plan.day()
LocalDay specifies date and time zone.endOfDay()
End time of the day, exclusive.default LocalTime
endTime()
Get the allowed latest time for this day.findAppointments
(Predicate<Appointment> filter) Finds all appointments matching given filter.findGapsFitting
(Duration duration) This method finds all time gaps that can accommodate an appointment of the given duration in natural order.findMatchingFreeSlotsOfDuration
(Duration duration, List<LocalDayPlan> plans) Find matching free time slots in this and other TimeLines.int
Returns the number of appointments on a day.removeAppointment
(Appointment appointment) Removes the given appointment, returning the AppointmentRequest of that appointment, if found.removeAppointments
(Predicate<Appointment> filter) Removes appointments with description that matches a filter.Start time of the day, inclusive.default LocalTime
Get the allowed first time for this day.toString()
Return a string containing the local date, the time zone and all appointments in natural order, presented with time as local time.
-
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
Get the allowed first time for this day.- Returns:
- the start time of this plan
-
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 datastart
- if not null, preferred start timefallback
- 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
Add and appointment with fix start time. This request can fail (Optional is not present) if the start time is not available.- Parameters:
appointmentData
- datastartTime
- fixed time- Returns:
- Optional Appointment
-
addAppointment
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
- datapreference
- time preference- Returns:
- Optional Appointment
-
removeAppointment
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
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
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
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
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. -
contains
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
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
Get the instant at the given hour and minute of this local day plan.- Parameters:
hour
- sicminute
- sic- Returns:
- the point in time as Instant
-