Interface TimeSlot

All Superinterfaces:
Comparable<TimeSlot>
All Known Subinterfaces:
Appointment

public interface TimeSlot extends Comparable<TimeSlot>
A time slot represents an (un)allocated range of time defined as [start,end). The starting square bracket and the parenthesis at the end of [start,end) mean that start is part of the slot, end belongs to the following and is the start thereof. In mathematics such notation is called a half open range. The implementer should implement a proper to string showing start instant, end instant and duration of this slot. The time slots are comparable by length of the slot only! If you keep the slots in a linked list there is no need to compare them by start or end time, because the list will keep them in natural order. The end should never be before start, however a TimeSlot with start and end equal, such that it has an effective duration of zero minutes, zero nanoseconds may have its use as for instance a sentinel value.
Author:
Pieter van den Hombergh p.vandenhombergh@fontys.nl
  • Method Details

    • getStart

      Instant getStart()
      Get the start of the TimeSlot. The start time is included in the range.
      Returns:
      the start time
    • getEnd

      Instant getEnd()
      Get the end of the TimeSlot. The end time is NOT included in the range.
      Returns:
      the end time
    • duration

      default Duration duration()
      Get the duration of this slot. The duration may be equal to "Duration.ZERO", typically used in sentinel values of TimeSlot.
      Returns:
      the duration as Duration
    • compareTo

      default int compareTo(TimeSlot other)
      Compare two time slots by length.
      Specified by:
      compareTo in interface Comparable<TimeSlot>
      Parameters:
      other - TimeSlot to compare with this one.
      Returns:
      comparison result, less than 0, 0 or greater 0.
    • fits

      default boolean fits(Duration duration)
      Is this time slot sufficient to accommodate a specified duration.
      Parameters:
      duration - to test
      Returns:
      true if start and end are sufficiently apart to fit the given duration.
    • fits

      default boolean fits(TimeSlot other)
      Does the given time slot fit inside this time slot.
      Parameters:
      other - Timeslot to test
      Returns:
      true if other does not start earlier nor ends earlier than this time slot.
    • getEndTime

      default LocalTime getEndTime(LocalDay day)
      Get End Time of the appointment in the given time zone.
      Parameters:
      day - for the time
      Returns:
      end Time.
    • getStartTime

      default LocalTime getStartTime(LocalDay day)
      Get Start Time of the appointment in given time zone.
      Parameters:
      day - for the time
      Returns:
      start Time
    • getStartDate

      default LocalDate getStartDate(LocalDay day)
      Return the date of the start of the TimeSlot.
      Parameters:
      day - provides time zone
      Returns:
      the date on which the TimeSlot starts.
    • getEndDate

      default LocalDate getEndDate(LocalDay day)
      Return the date of the end of the TimeSlot.
      Parameters:
      day - provides time zone
      Returns:
      the date on which the TimeSlot ends.