Class NewRoomDTO

java.lang.Object
de.gustavblass.fsu.fmi.roombooking.dto.NewRoomDTO

public class NewRoomDTO extends Object
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 individualEquipment and commonEquipment JSON 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 Details

  • Constructor Details

    • NewRoomDTO

      public NewRoomDTO()
  • Method Details

    • initialiseIndividualEquipment

      public void initialiseIndividualEquipment(int size)
      Adds n := size items of empty IndividualEquipmentMutableDTO to the individualEquipment. (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 the individualEquipment.
      Parameters:
      individualEquipment - The new individualEquipment. No IndividualEquipmentType must 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 the commonEquipment.
      Parameters:
      commonEquipment - The new common equipment. No CommonEquipmentType must occur more than once.
      Throws:
      de.gustavblass.commons.exceptions.IllegalArgumentException - If one of the common-equipment types occurs more than once.
    • getIndividualEquipment

      @NonNull public @NonNull List<IndividualEquipmentMutableDTO> getIndividualEquipment()
      Returns:
      The individualEquipment.
      Implementation Note:
      Spring uses the reference of the individualEquipment list 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

      @Contract(pure=true) @NonNull public @NonNull Set<String> getCommonEquipment()
      Returns:
      The commonEquipment. Empty if no common equipment is defined.