Class Reservation
- All Implemented Interfaces:
Identified, Comparable<Reservation>
- Direct Known Subclasses:
SeatReservation
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether theapplicantis reliant on proper accessibility, possibly due to temporarily or permanently impaired mobility.private @NonNull ActorTheActorwho has placed this Reservation.private @NonNull LocalDateTimeprivate @NonNull LongIdentifies this Reservation uniquely.private @NonNull IntendedUseprivate @NonNull LocalDateTimeThe date and time at which the applicant first requested this Reservation.private final @NonNull Set<RequiredCommonEquipment> private final @NonNull Set<RequiredIndividualEquipment> private @NonNull Roomprivate @NonNull LocalDateTime -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRequiredCommonEquipment(@NonNull RequiredCommonEquipment equipment) Inserts a piece of common equipment to therequiredCommonEquipmentset.voidaddRequiredIndividualEquipment(@NonNull RequiredIndividualEquipment equipment) Insert a new piece of individual equipment into therequiredIndividualEquipmentset.@Range(from=-1L,to=1L) intcompareTo(@NonNull Reservation other) Determines whether this Reservation or a conflicting other Reservation has higher priority.@Range(from=0L,to=1L) double@NonNull @Unmodifiable Set<RequiredCommonEquipment> @NonNull @Unmodifiable Set<RequiredIndividualEquipment> @Range(from=0L,to=1L) doubleDetermines how well the givenRoomis suited for this Reservation, based on the accessibility, the intended use and the required vs.voidremoveAllRequiredCommonEquipment(@NonNull CommonEquipmentType type) Removes all pieces of common equipment from therequiredCommonEquipmentset that match the givenCommonEquipmentType.voidremoveAllRequiredCommonEquipment(@NonNull Collection<RequiredCommonEquipment> equipment) Removes several pieces of common equipment from therequiredCommonEquipmentset.voidremoveAllRequiredIndividualEquipment(@NonNull IndividualEquipmentType type) Removes all pieces of individual equipment from therequiredIndividualEquipmentset that match the givenIndividualEquipmentType.voidremoveAllRequiredIndividualEquipment(@NonNull Collection<RequiredIndividualEquipment> equipment) Removes several pieces of individual equipment from therequiredIndividualEquipmentset.voidremoveRequiredCommonEquipment(@NonNull RequiredCommonEquipment equipment) Removes a piece of common equipment from therequiredCommonEquipmentset.voidremoveRequiredIndividualEquipment(@NonNull RequiredIndividualEquipment equipment) Removes a piece of individual equipment from therequiredIndividualEquipmentset.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Identified
getId
-
Field Details
-
id
Identifies this Reservation uniquely. -
applicant
-
requestDate
-
startDate
Specifies the date and time at which the interval begins during which the
roomis blocked for use by theapplicant. The start date may be in the future (then, this object is “only” a reservation for later) or in the past (then, theapplicanthas possibly already entered the room and begun using it).Must always come before the
endDate! -
endDate
Specifies the date and time at which the interval ends during which the
roomis blocked for use by theapplicant. The end date may be in the future (then, theapplicantwill have or still have the right to use the room) or in the past (then, the reservation has expired and the applicant is no longer permitted to use the room).Must always come after the
startDate! -
room
-
requiredIndividualEquipment
The individual equipment that theapplicantneeds for theirintendedUse. Not guaranteed to be available in theroom. -
requiredCommonEquipment
The common equipment that theapplicantneeds for theirintendedUse. Not guaranteed to be available in theroom. -
accessibilityRequired
private boolean accessibilityRequiredWhether theapplicantis reliant on proper accessibility, possibly due to temporarily or permanently impaired mobility. Not guaranteed to be offered by theroom. -
intendedUse
-
-
Constructor Details
-
Reservation
public Reservation()
-
-
Method Details
-
getRequiredIndividualEquipment
@Contract(pure=true) @NonNull public @NonNull @Unmodifiable Set<RequiredIndividualEquipment> getRequiredIndividualEquipment()- Returns:
- A copy of the
requiredIndividualEquipment.
-
getRequiredCommonEquipment
@Contract(pure=true) @NonNull public @NonNull @Unmodifiable Set<RequiredCommonEquipment> getRequiredCommonEquipment()- Returns:
- A copy of the
requiredCommonEquipment.
-
addRequiredIndividualEquipment
Insert a new piece of individual equipment into therequiredIndividualEquipmentset.- Parameters:
equipment- Additional individual equipment needed by theapplicantfor theintendedUseof theroom.
-
removeRequiredIndividualEquipment
public void removeRequiredIndividualEquipment(@NonNull @NonNull RequiredIndividualEquipment equipment) Removes a piece of individual equipment from therequiredIndividualEquipmentset.- Parameters:
equipment- Individual equipment not needed any longer by theapplicantfor theintendedUseof theroom.
-
removeAllRequiredIndividualEquipment
public void removeAllRequiredIndividualEquipment(@NonNull @NonNull Collection<RequiredIndividualEquipment> equipment) Removes several pieces of individual equipment from therequiredIndividualEquipmentset.- Parameters:
equipment- Individual equipment not needed any longer by theapplicantfor theintendedUseof theroom.
-
removeAllRequiredIndividualEquipment
Removes all pieces of individual equipment from therequiredIndividualEquipmentset that match the givenIndividualEquipmentType.- Parameters:
type- The type of individual equipment no longer needed by theapplicantfor theintendedUseof theroom.
-
addRequiredCommonEquipment
Inserts a piece of common equipment to therequiredCommonEquipmentset.- Parameters:
equipment- The additional common equipment needed by theapplicantfor theintendedUseof theroom.
-
removeRequiredCommonEquipment
Removes a piece of common equipment from therequiredCommonEquipmentset.- Parameters:
equipment- Common equipment not needed any longer by theapplicantfor theintendedUseof theroom.
-
removeAllRequiredCommonEquipment
public void removeAllRequiredCommonEquipment(@NonNull @NonNull Collection<RequiredCommonEquipment> equipment) Removes several pieces of common equipment from therequiredCommonEquipmentset.- Parameters:
equipment- Common equipment no longer by theapplicantfor theintendedUseof theroom.
-
removeAllRequiredCommonEquipment
Removes all pieces of common equipment from therequiredCommonEquipmentset that match the givenCommonEquipmentType.- Parameters:
type- The type of common equipment no longer needed by theapplicantfor theintendedUseof theroom.
-
computeScore
@Contract(pure=true) public @Range(from=0L,to=1L) double computeScore()- Returns:
- Score indicating how well the Room matches this Reservation.
-
matches
Determines how well the given
Roomis suited for this Reservation, based on the accessibility, the intended use and the required vs. available equipment.Accessibility score
Accessibilityscore :=- accessibility is not required: 1
- accessibility is required:
Accessibility score ∈ [0, 1]
Use-case score
Use-case score :=
intendedUse=IntendedUse.STUDYING:- Room =
QuietStudyRoom: 1 - else: ½
- Room =
- else:
- Room =
ConferenceRoom: 1 - else: 0
- Room =
Use-case score ∈ [0, 1]
Equipment score
IndividualEquipmentscore := (ΣrequiredIndividualEquipmentavailable in the Room) / (requiredIndividualEquipment.size)CommonEquipmentscore := (ΣrequiredCommonEquipmentavailable in the Room) / (requiredCommonEquipment.size)- equipment score := ½ individual-equipment score + ½ common-equipment score
Equipment score ∈ [0, 1]
Total score
Total score := ½ accessibility score + ½ (¾ equipment score + ¼ use-case score)
Total score ∈ [0, 1]
- Parameters:
room- The Room which this Reservation shall be matched to.- Returns:
- How well the Room matches this Reservation's requirements.
-
compareTo
@Contract(pure=true) public @Range(from=-1L,to=1L) int compareTo(@NonNull @NonNull Reservation other) throws IllegalArgumentException Determines whether this Reservation or a conflicting other Reservation has higher priority. “Conflicting” means that both Reservations reference the same
room. (Currently, thestartDateandendDatefields are not taken into account, though.)The priority is determined based on the result of
matches(Room)for both Reservations.- Specified by:
compareToin interfaceComparable<Reservation>- Parameters:
other- A second, different Reservation for the sameroom.- Returns:
- Greater than zero if this Reservation matches the Room better than the other Reservation does. Zero if both reservations match equally well. Negative if this Reservation matches worse than the other one.
- Throws:
IllegalArgumentException- If theroomfields differ.
-