public class BaseAppointmentHelper extends Object
Modifier and Type | Field and Description |
---|---|
static LocalDate |
WEEK_START
The week to use for the UI that lets the user configure the available
AppointmentSlot s. |
Constructor and Description |
---|
BaseAppointmentHelper() |
Modifier and Type | Method and Description |
---|---|
static List<AppointmentSlot> |
applySlotConstraints(List<AppointmentSlot> slots,
AppointmentTemplate template)
Sanitizes the given slots so that they conform the restrictions imposed by the given appointment template.
|
static com.google.common.collect.ImmutableRangeSet<Instant> |
createClosedDateTimeRanges(List<AppointmentClosingTime> closingTimes,
com.google.common.collect.BoundType boundType,
ZoneId sourceZone)
Creates the temporal disjoint intervals corresponding the given closing times.
|
static List<AppointmentSlot> |
createDefaultSlots()
Creates the default
AppointmentTemplate.getSlots() when none are set yet. |
static AppointmentSlot |
createSlot(LocalDateTime dateTime)
Creates a new slot starting at the given date.
|
static com.google.common.collect.Range<LocalDateTime> |
getSlotDateTime(AppointmentSlot slot) |
static com.google.common.collect.Range<LocalDateTime> |
getSlotDateTimeRange(AppointmentSlot slot)
Returns the date time range of the given slot.
|
static LocalDateTime |
getSlotFromDateTime(AppointmentSlot slot) |
static LocalDateTime |
getSlotToDateTime(AppointmentSlot slot) |
static LocalTime |
getTimeOnGrid(LocalTime time,
Duration duration)
Adjusts the given time to a time that lies on the grid defined by the appointment type.
|
static boolean |
isSlotOverlapping(AppointmentTemplate template,
AppointmentSlot slot)
Checks whether the given slot is overlapping any slot of the given template.
|
static AppointmentSlot |
mergeOverlappingSlots(AppointmentSlot lhs,
AppointmentSlot rhs)
Takes two overlapping slots and creates a new slot with the start and end time set to the overlapping interval.
|
static List<AppointmentSlot> |
mergeOverlappingSlots(List<AppointmentSlot> slots)
Merges all overlapping slots.
|
public static final LocalDate WEEK_START
AppointmentSlot
s.public static List<AppointmentSlot> applySlotConstraints(List<AppointmentSlot> slots, AppointmentTemplate template)
slots
- Slots to constrain.template
- Template to which the slots must adhere.public static com.google.common.collect.ImmutableRangeSet<Instant> createClosedDateTimeRanges(List<AppointmentClosingTime> closingTimes, com.google.common.collect.BoundType boundType, ZoneId sourceZone)
closingTimes
- List of closing times to process.boundType
- Whether to create closed or open ranges from the closing times.sourceZone
- The source time zone in which the given closing times are interpreted. Should usually be the
AppointmentTemplate.getZoneId()
of the AppointmentClosingTime.getAppointmentTemplate()
.public static List<AppointmentSlot> createDefaultSlots()
AppointmentTemplate.getSlots()
when none are set yet.public static AppointmentSlot createSlot(LocalDateTime dateTime)
dateTime
- Starting date for the new slot.public static com.google.common.collect.Range<LocalDateTime> getSlotDateTime(AppointmentSlot slot)
slot
- A slot to process.WEEK_START
.public static com.google.common.collect.Range<LocalDateTime> getSlotDateTimeRange(AppointmentSlot slot)
slot
- A slot to process.public static LocalDateTime getSlotFromDateTime(AppointmentSlot slot)
slot
- A slot to use.WEEK_START
.public static LocalDateTime getSlotToDateTime(AppointmentSlot slot)
slot
- A slot to use.WEEK_START
.public static LocalTime getTimeOnGrid(LocalTime time, Duration duration)
time
- A local time to process.duration
- Duration of the grid.public static boolean isSlotOverlapping(AppointmentTemplate template, AppointmentSlot slot)
template
- An AppointmentTemplate
with slots.slot
- A slot to check.true
if the given slot has any overlap with any slot of the given template.public static AppointmentSlot mergeOverlappingSlots(AppointmentSlot lhs, AppointmentSlot rhs)
lhs
- First slot to merge.rhs
- Seconds slot to merge.public static List<AppointmentSlot> mergeOverlappingSlots(List<AppointmentSlot> slots)
slots
- List of slots to merge.Copyright © 2020 XIMA MEDIA GmbH. All rights reserved.