Class NewRoomDTO
java.lang.Object
de.gustavblass.fsu.fmi.roombooking.dto.NewRoomDTO
A data-transfer object that represents a
Room to be newly added to the database.- Implementation Note:
This DTO is a class and not a record, in order to validate that the
individualEquipmentandcommonEquipmentJSON collections do not contain duplicates. If Jackson deserialised the JSON arrays into Sets, then the duplicates would be swallowed without an error. Thus, the client would not understand that its request was actually malformed.So, instead, this is manually checked, and an exception is thrown manually.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate @Nullable AccessibilityTheRoom.accessibility.private @Nullable Map<String, IndividualEquipmentMutableDTO> Remembers the return value ofgetIndividualEquipmentMap()until theindividualEquipmentis updated.private @NotNull @Min(1L) @Nullable IntegerTheRoom.capacity.private @NotNull @Nullable IntegerTheRoom.floor.private @NonNull List<IndividualEquipmentMutableDTO> TheRoom.equipment.private @Nullable StringTheRoom.notes.private @NotNull @NotBlank @Pattern(regexp="^[0-9\\p{L}'\u2019/.,-_\\s+]+$") @Nullable StringTheRoom.number.private @NotNull @Nullable RoomType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEmptyIndividualEquipment(int size) @NonNull List<IndividualEquipmentMutableDTO> @NonNull @Unmodifiable Map<String, IndividualEquipmentMutableDTO> voidinitialiseIndividualEquipment(int size) voidsetCommonEquipment(@NonNull Collection<String> commonEquipment) Updates thecommonEquipment.voidsetIndividualEquipment(Collection<IndividualEquipmentMutableDTO> individualEquipment) Updates theindividualEquipment.
-
Field Details
-
number
@NotNull @NotBlank @Pattern(regexp="^[0-9\\p{L}'\u2019/.,-_\\s+]+$") @Nullable private @NotNull @NotBlank @Pattern(regexp="^[0-9\\p{L}'\u2019/.,-_\\s+]+$") @Nullable String numberTheRoom.number. -
type
-
floor
TheRoom.floor. -
capacity
TheRoom.capacity. -
individualEquipment
TheRoom.equipment. -
commonEquipment
-
accessibility
TheRoom.accessibility. -
notes
TheRoom.notes. -
cachedIndividualEquipmentMap
Remembers the return value ofgetIndividualEquipmentMap()until theindividualEquipmentis updated.
-
-
Constructor Details
-
NewRoomDTO
public NewRoomDTO()
-
-
Method Details
-
initialiseIndividualEquipment
public void initialiseIndividualEquipment(int size) Addsn := sizeitems of emptyIndividualEquipmentMutableDTOto theindividualEquipment. (All previous elements are cleared).- Parameters:
size- The number of new elements to be added.- Implementation Note:
- Clears the
cachedIndividualEquipmentMap.
-
addEmptyIndividualEquipment
public void addEmptyIndividualEquipment(int size) - Parameters:
size- The number of new elements to be added.- Implementation Note:
- Clears the
cachedIndividualEquipmentMap.
-
setIndividualEquipment
public void setIndividualEquipment(Collection<IndividualEquipmentMutableDTO> individualEquipment) throws de.gustavblass.commons.exceptions.IllegalArgumentException Updates theindividualEquipment.- Parameters:
individualEquipment- The newindividualEquipment. NoIndividualEquipmentTypemust occur more than once.- Throws:
de.gustavblass.commons.exceptions.IllegalArgumentException- If one of the individual-equipment types occurs more than once.- Implementation Note:
- Clears the
cachedIndividualEquipmentMap.
-
setCommonEquipment
public void setCommonEquipment(@NonNull @NonNull Collection<String> commonEquipment) throws de.gustavblass.commons.exceptions.IllegalArgumentException Updates thecommonEquipment.- Parameters:
commonEquipment- The new common equipment. NoCommonEquipmentTypemust occur more than once.- Throws:
de.gustavblass.commons.exceptions.IllegalArgumentException- If one of the common-equipment types occurs more than once.
-
getIndividualEquipment
- Returns:
- The
individualEquipment. - Implementation Note:
- Spring uses the reference of the
individualEquipmentlist to fill in the actual form inputs. To the author's current knowledge, there is no alternative to this violation of good programming practices.
-
getIndividualEquipmentMap
@NonNull public @NonNull @Unmodifiable Map<String, IndividualEquipmentMutableDTO> getIndividualEquipmentMap()- Returns:
- The
individualEquipmentas aMapwhere theIndividualEquipmentMutableDTO.typeserves as the key and the DTO itself as the value. - Implementation Note:
- Returns the
cachedIndividualEquipmentMapif not null.
-
getCommonEquipment
- Returns:
- The
commonEquipment. Empty if no common equipment is defined.
-