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.
- Author:
- Pieter van den Hombergh
p.vandenhombergh@fontys.nl
-
Method Summary
Modifier and TypeMethodDescriptiondefault Optional
<Appointment> addAppointment
(AppointmentData appointmentData, TimePreference preference) Add and appointment with time preference.default Optional
<Appointment> addAppointment
(AppointmentData appointmentData, LocalTime startTime) Add and appointment with fix start time.default Optional
<Appointment> addAppointment
(AppointmentData appointmentData, LocalTime start, TimePreference fallback) Add an appointment with start time and fallback time preference.default List
<Appointment> default Instant
at
(int hour, int minute) Get the instant at the given hour and minute of this local day plan.default boolean
canAddAppointmentOfDuration
(Duration duration) default boolean
contains
(Appointment 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.default List
<Appointment> findAppointments
(Predicate<Appointment> filter) findGapsFitting
(Duration duration) findGapsFittingLargestFirst
(Duration duration) findGapsFittingReversed
(Duration duration) findGapsFittingSmallestFirst
(Duration duration) findMatchingFreeSlotsOfDuration
(Duration duration, List<LocalDayPlan> plans) default int
default AppointmentRequest
removeAppointment
(Appointment appointment) default List
<AppointmentRequest> removeAppointments
(Predicate<Appointment> filter) Start time of the day, inclusive.default LocalTime
Get the allowed first time for this day.timeline()
Get the timeline used by this LocalDayPlan.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
-
timeline
Timeline timeline()Get the timeline used by this LocalDayPlan.- Returns:
- the timeline used by this LocalDayPlan
-
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
default 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
default 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
- datapreference
- time preference- Returns:
- Optional Appointment
-
removeAppointment
- Parameters:
appointment
- the appointment to remove- Returns:
- AppointmentRequest, the original appointment request
-
removeAppointments
- Parameters:
filter
- to remove all appointments that match- Returns:
- all appointment requests of removed appointments
-
appointments
- Returns:
- all appointments
-
findMatchingFreeSlotsOfDuration
- Parameters:
duration
- Minimum duration of the slotsplans
- 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
- Parameters:
duration
- the minimum duration that should fit- Returns:
- list of timeslots that fit the duration
-
findGapsFittingReversed
- Parameters:
duration
- the minimum duration that should fit- Returns:
- list of timeslots that fit the duration
-
findGapsFittingLargestFirst
- Parameters:
duration
- the minimum duration- Returns:
- list of gaps fitting the duration
-
findGapsFittingSmallestFirst
- Parameters:
duration
- the minimum duration- Returns:
- list of timeslots fitting the duration
-
canAddAppointmentOfDuration
- Parameters:
duration
- the minimum duration- Returns:
- true of a gap is available, false otherwise
-
findAppointments
- Parameters:
filter
- to find appointments- Returns:
- list of appointments that fit the filter
-
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
- Parameters:
appointment
- the appointment to check- Returns:
- true if present, false otherwise
-
date
What is the (start) date of this plan.- Returns:
- the date according to this LocalDayPlan's time zone
-
nrOfAppointments
default int nrOfAppointments()- Returns:
- number of appointments
-
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
-