Class Room

java.lang.Object
de.gustavblass.fsu.fmi.roombooking.model.room.Room
All Implemented Interfaces:
Identified
Direct Known Subclasses:
ConferenceRoom, QuietStudyRoom

@Entity public abstract class Room extends Object implements Identified

Represents a room in the FMI building at Inselplatz.

The table column type determines whether a Room is a ConferenceRoom or a QuietStudyRoom.

  • Field Details

    • id

      @NonNull private @NonNull Long id
      Identifies this Room uniquely.
    • floor

      @Nullable private @Nullable Integer floor
      The number of the floor this Room is to be found on, if it is located in a multi-storey building.
    • number

      @NonNull private @NonNull String number
      Human-friendly identifier of the room. Usually, this is just a small series of digits (e.g. 123, 42 or 13), but it cannot be ruled out that some room numbers include letters. Must not be blank!
    • capacity

      private @Range(from=1L,to=2147483647L) int capacity
      How many seats there are, i.e. how many occupants this Room can accomodate.
    • equipment

      @NonNull private final @NonNull Set<IndividualEquipment> equipment
      The IndividualEquipment suitable for use by one person each that is available in this Room. There can only be one IndividualEquipment object per RoomEquipment.type.
    • accessibility

      @Nullable private @Nullable Accessibility accessibility
      How well this Room is suited for mobility-impaired users.
    • notes

      @Nullable private @Nullable String notes
      Useful information about this Room, possibly displayed to end users when placing a Reservation.
    • reservations

      @NonNull private final @NonNull Set<Reservation> reservations
      The Reservations that are associated with this Room.
  • Constructor Details

    • Room

      public Room()
      Do not use this constructor! It exists solely for Spring Data JPA.
    • Room

      public Room(@NonNull @Range(from=1L,to=2147483647L) @NonNull Long id, @NotBlank @NonNull @NotBlank @NonNull String number, @Range(from=1L,to=2147483647L) int capacity) throws de.gustavblass.commons.exceptions.IllegalArgumentException
      Constructs a new Room object with the id, number and capacity.
      Parameters:
      id - Identifies this Room uniquely.
      number - Human-friendly identifier. Must not be blank!
      capacity - Number of people that can use this Room simultaneously.
      Throws:
      de.gustavblass.commons.exceptions.IllegalArgumentException - If the room number is blank.
  • Method Details

    • getType

      @Contract(pure=true) @NonNull public abstract @NonNull RoomType getType()
      Returns:
      The RoomType of the extending class. Determines the kind of room.
    • setCapacity

      public void setCapacity(@Range(from=1L,to=2147483647L) int capacity) throws de.gustavblass.commons.exceptions.IllegalArgumentException
      Updates the capacity.
      Parameters:
      capacity - Number of users that can simultaneously be in this Room. Must be greater than zero.
      Throws:
      de.gustavblass.commons.exceptions.IllegalArgumentException - If the capacity is smaller than one.
    • addIndividualEquipment

      public void addIndividualEquipment(@NonNull @NonNull IndividualEquipment equipment)
      Replaces the IndividualEquipment in equipment that has same type as the given equipment with the given equipment.
      Parameters:
      equipment - The equipment that shall replace the currently present equipment of the same IndividualEquipment type.
    • addReservation

      public void addReservation(@NonNull @NonNull Reservation reservation)
      Inserts the given Reservation into the reservations set.
      Parameters:
      reservation - The new reservation.
    • removeIndividualEquipment

      public void removeIndividualEquipment(@NonNull @NonNull IndividualEquipment equipment)
      Deletes the given IndividualEquipment from the equipment set.
      Parameters:
      equipment - The IndividualEquipment that shall no longer be available in this Room.
    • removeAllIndividualEquipment

      public void removeAllIndividualEquipment(@NonNull @NonNull Collection<IndividualEquipment> equipment)
      Deletes multiple IndividualEquipment from the equipment set.
      Parameters:
      equipment - The IndividualEquipment that shall no longer be present in this Room.
    • removeAllIndividualEquipment

      public void removeAllIndividualEquipment(@NonNull @NonNull IndividualEquipmentType type)
      Deletes the IndividualEquipment object with the given RoomEquipment.type from the equipment set.
      Parameters:
      type - The IndividualEquipmentType that shall no longer be present in this Room.
    • getFloor

      @Contract(pure=true) @NonNull public @NonNull Optional<Integer> getFloor()
      Returns:
      The floor of this Room.
    • getIndividualEquipment

      @Contract(pure=true) @NonNull public @NonNull Set<IndividualEquipment> getIndividualEquipment()
      Returns a copy of the equipment set.
      Returns:
      Copy of the IndividualEquipmentType present in this Room.
    • getIndividualEquipment

      @Contract(pure=true) @NonNull public @NonNull Optional<IndividualEquipment> getIndividualEquipment(@NonNull @NonNull IndividualEquipmentType type)
      Finds the IndividualEquipment in the equipment of the given RoomEquipment.type. Note that there is only one IndividualEquipment object of each IndividualEquipmentType! You probably do not need to call this method.
      Parameters:
      type - The IndividualEquipmentType that the returned IndividualEquipment object shall match.
      Returns:
      The IndividualEquipment matching the given type, if existent.
    • getReservations

      @Contract(pure=true) @NonNull public @NonNull Set<Reservation> getReservations()
      Returns a copy of the reservations set.
      Returns:
      Copy of the Reservations placed for this Room.
    • getAccessibility

      @Contract(pure=true) @NonNull public @NonNull Optional<Accessibility> getAccessibility()
      Returns:
      The accessibility if known.
    • getNotes

      @Contract(pure=true) @NonNull public @NonNull Optional<String> getNotes()
      Returns:
      The notes if present.