Record Class RoomScheduleItem

java.lang.Object
java.lang.Record
de.gustavblass.fsu.fmi.roombooking.model.room.schedule.RoomScheduleItem
Record Components:
status - Whether the schedule's Room is RoomStatus.FREE or RoomStatus.OCCUPIED.
startTime - The status() is valid only after this LocalTime for the Room.
endTime - The status() is valid only before this LocalTime for the Room.
occupancy - If set, the number of seats occupied by SeatReservations. If unset, the whole Room is reserved. Use getOccupancy() for null-safe access.

public record RoomScheduleItem(@NonNull RoomStatus status, @NonNull LocalTime startTime, @NonNull LocalTime endTime, @Nullable @Range(from=0L,to=2147483647L) Integer occupancy) extends Record
A single element of a RoomSchedule.
  • Field Details

    • status

      @NonNull private final @NonNull RoomStatus status
      The field for the status record component.
    • startTime

      @NonNull private final @NonNull LocalTime startTime
      The field for the startTime record component.
    • endTime

      @NonNull private final @NonNull LocalTime endTime
      The field for the endTime record component.
    • occupancy

      @Nullable private final @Nullable @Range(from=0L,to=2147483647L) Integer occupancy
      The field for the occupancy record component.
  • Constructor Details

    • RoomScheduleItem

      public RoomScheduleItem(@NonNull @NonNull RoomStatus status, @NonNull @NonNull LocalTime startTime, @NonNull @NonNull LocalTime endTime, @Nullable @Nullable @Range(from=0L,to=2147483647L) Integer occupancy)
      Constructs a new schedule element.
      Parameters:
      status - The status.
      startTime - The startTime. Must come before the endTime!
      endTime - The endTime. Must come after the startTime!
      occupancy - The occupancy. Will be ignored if negative.
      API Note:
      If the endTime comes before the startTime, they will simply be swapped without throwing an exception.
  • Method Details

    • getOccupancy

      @Contract(pure=true) @NonNull public @NonNull Optional<Integer> getOccupancy()
      Returns:
      The occupancy, if set.
    • getDuration

      @Contract(pure=true) @NonNull public @NonNull Duration getDuration()
      Returns:
      The Duration.between(Temporal, Temporal) the startTime and endTime.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • status

      @NonNull public @NonNull RoomStatus status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • startTime

      @NonNull public @NonNull LocalTime startTime()
      Returns the value of the startTime record component.
      Returns:
      the value of the startTime record component
    • endTime

      @NonNull public @NonNull LocalTime endTime()
      Returns the value of the endTime record component.
      Returns:
      the value of the endTime record component
    • occupancy

      @Nullable public @Nullable @Range(from=0L,to=2147483647L) Integer occupancy()
      Returns the value of the occupancy record component.
      Returns:
      the value of the occupancy record component