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 @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 TypeMethodDescription@NonNull List<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.
-
-
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.
-
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.
-
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.
-
getCommonEquipment
- Returns:
- The
commonEquipment. Empty if no common equipment is defined.
-