From 87df96760ddf4003698b123549544f65f2613221 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Tue, 12 May 2020 15:44:32 +0200 Subject: [PATCH] Added lombok and converted DTOs --- build.gradle | 1 + lombok.config | 3 ++ .../smarthut/controller/GuestController.java | 2 +- .../dto/AutomationFastUpdateRequest.java | 34 +------------ .../smarthut/dto/AutomationSaveRequest.java | 16 +----- .../dto/BooleanTriggerSaveRequest.java | 30 +---------- .../smarthut/dto/ButtonDimmerDimRequest.java | 18 +------ .../smarthut/dto/DeviceSaveRequest.java | 26 +--------- .../smarthut/dto/DimmableSaveRequest.java | 34 +------------ .../dto/DimmableStateSaveRequest.java | 14 +---- .../dto/GenericDeviceSaveReguest.java | 18 +------ .../smarthut/dto/GuestPermissionsRequest.java | 11 ++-- .../smarthut/dto/GuestsUpdateRequest.java | 4 +- .../dto/InitPasswordResetRequest.java | 10 +--- .../sanmarinoes/smarthut/dto/JWTRequest.java | 30 +---------- .../sanmarinoes/smarthut/dto/JWTResponse.java | 13 ++--- .../smarthut/dto/KnobDimmerDimRequest.java | 18 +------ .../smarthut/dto/PasswordResetRequest.java | 18 +------ .../smarthut/dto/RangeTriggerSaveRequest.java | 42 +-------------- .../smarthut/dto/RoomSaveRequest.java | 34 +------------ .../dto/ScenePrioritySaveRequest.java | 26 +--------- .../smarthut/dto/SceneSaveRequest.java | 30 +---------- .../smarthut/dto/SensorSaveRequest.java | 51 +------------------ .../smarthut/dto/SwitchOperationRequest.java | 18 +------ .../smarthut/dto/SwitchableSaveRequest.java | 34 +------------ .../dto/SwitchableStateSaveRequest.java | 14 +---- .../smarthut/dto/ThermostatSaveRequest.java | 50 +----------------- .../smarthut/dto/UserRegistrationRequest.java | 34 +------------ .../smarthut/dto/UserResponse.java | 16 +----- .../smarthut/dto/UserUpdateRequest.java | 48 ----------------- 30 files changed, 62 insertions(+), 635 deletions(-) create mode 100644 lombok.config delete mode 100644 src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserUpdateRequest.java diff --git a/build.gradle b/build.gradle index 4f04b96..a6f73d3 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ plugins { id 'java' id 'jacoco' id "org.sonarqube" version "2.8" + id 'io.freefair.lombok' version '5.0.1' } group = 'ch.usi.inf.sa4.sanmarinoes' version = '0.0.1-SNAPSHOT' diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..189c0be --- /dev/null +++ b/lombok.config @@ -0,0 +1,3 @@ +# This file is generated by the 'io.freefair.lombok' Gradle plugin +config.stopBubbling = true +lombok.addLombokGeneratedAnnotation = true diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/GuestController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/GuestController.java index 4b7109d..8212426 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/GuestController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/GuestController.java @@ -46,7 +46,7 @@ public class GuestController { @PutMapping("/guests") public List setGuests( @RequestBody @Valid GuestsUpdateRequest g, final Principal principal) { - Iterable guests = userRepository.findAllById(g.ids); + Iterable guests = userRepository.findAllById(g.getIds()); User host = userRepository.findByUsername(principal.getName()); for (final User oldGuest : host.getGuests()) { diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationFastUpdateRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationFastUpdateRequest.java index 58ce46c..1fd45ea 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationFastUpdateRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationFastUpdateRequest.java @@ -8,7 +8,9 @@ import java.util.List; import javax.validation.constraints.Min; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class AutomationFastUpdateRequest { public abstract static class TriggerDTO { @NotNull public long deviceId; @@ -62,36 +64,4 @@ public class AutomationFastUpdateRequest { @NotNull private long id; @NotNull @NotEmpty private String name; - - public long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public List getScenes() { - return scenes; - } - - public void setScenes(List scenes) { - this.scenes = scenes; - } - - public List getTriggers() { - return triggers; - } - - public void setTriggers(List triggers) { - this.triggers = triggers; - } - - public void setId(long id) { - this.id = id; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationSaveRequest.java index bcd1f8b..00f0c07 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/AutomationSaveRequest.java @@ -2,22 +2,10 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class AutomationSaveRequest { - private long id; - @NotNull @NotEmpty private String name; - - public long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanTriggerSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanTriggerSaveRequest.java index 2c08bc0..8f57b22 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanTriggerSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanTriggerSaveRequest.java @@ -1,7 +1,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class BooleanTriggerSaveRequest { private long id; @@ -11,32 +13,4 @@ public class BooleanTriggerSaveRequest { @NotNull private Long automationId; private boolean on; - - public long getId() { - return id; - } - - public Long getDeviceId() { - return deviceId; - } - - public void setDeviceId(Long deviceId) { - this.deviceId = deviceId; - } - - public Long getAutomationId() { - return automationId; - } - - public void setAutomationId(Long automationId) { - this.automationId = automationId; - } - - public boolean isOn() { - return on; - } - - public void setOn(boolean on) { - this.on = on; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ButtonDimmerDimRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ButtonDimmerDimRequest.java index 8e07015..4e15ef5 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ButtonDimmerDimRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ButtonDimmerDimRequest.java @@ -1,8 +1,10 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.NotNull; +import lombok.Data; /** A 'dim' event from a button dimmer. */ +@Data public class ButtonDimmerDimRequest { /** The device id */ @@ -15,20 +17,4 @@ public class ButtonDimmerDimRequest { /** Whether the dim is up or down */ @NotNull private DimType dimType; - - public DimType getDimType() { - return dimType; - } - - public void setDimType(DimType dimType) { - this.dimType = dimType; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DeviceSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DeviceSaveRequest.java index a975117..72b9ea7 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DeviceSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DeviceSaveRequest.java @@ -2,7 +2,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class DeviceSaveRequest { /** Device identifier */ private long id; @@ -15,28 +17,4 @@ public class DeviceSaveRequest { /** The name of the device as assigned by the user (e.g. 'Master bedroom light') */ @NotNull @NotEmpty private String name; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public Long getRoomId() { - return roomId; - } - - public void setRoomId(Long roomId) { - this.roomId = roomId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DimmableSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DimmableSaveRequest.java index acefa72..31325c3 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DimmableSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DimmableSaveRequest.java @@ -3,7 +3,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class DimmableSaveRequest { /** Device id (used only for update requests) */ @@ -23,36 +25,4 @@ public class DimmableSaveRequest { /** The name of the device as assigned by the user (e.g. 'Master bedroom light') */ @NotNull private String name; - - public void setRoomId(Long roomId) { - this.roomId = roomId; - } - - public void setName(String name) { - this.name = name; - } - - public Long getRoomId() { - return roomId; - } - - public String getName() { - return name; - } - - public Integer getIntensity() { - return intensity; - } - - public void setIntensity(Integer intensity) { - this.intensity = intensity; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DimmableStateSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DimmableStateSaveRequest.java index ebf99eb..00f875b 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DimmableStateSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/DimmableStateSaveRequest.java @@ -3,7 +3,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class DimmableStateSaveRequest { /** Device id (used only for update requests) */ @@ -13,16 +15,4 @@ public class DimmableStateSaveRequest { @Min(0) @Max(100) private Integer intensity = 0; - - public Integer getIntensity() { - return intensity; - } - - public void setIntensity(Integer intensity) { - this.intensity = intensity; - } - - public Long getId() { - return id; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GenericDeviceSaveReguest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GenericDeviceSaveReguest.java index 8ec2671..f3616e3 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GenericDeviceSaveReguest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GenericDeviceSaveReguest.java @@ -1,7 +1,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class GenericDeviceSaveReguest { /** * The room this device belongs in, as a foreign key id. To use when updating and inserting from @@ -11,20 +13,4 @@ public class GenericDeviceSaveReguest { /** The name of the device as assigned by the user (e.g. 'Master bedroom light') */ @NotNull private String name; - - public void setRoomId(Long roomId) { - this.roomId = roomId; - } - - public void setName(String name) { - this.name = name; - } - - public Long getRoomId() { - return roomId; - } - - public String getName() { - return name; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GuestPermissionsRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GuestPermissionsRequest.java index 8c1a2c4..17da407 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GuestPermissionsRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GuestPermissionsRequest.java @@ -1,13 +1,8 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; +import lombok.Data; + +@Data public class GuestPermissionsRequest { private boolean cameraEnabled; - - public boolean isCameraEnabled() { - return cameraEnabled; - } - - public void setCameraEnabled(boolean cameraEnabled) { - this.cameraEnabled = cameraEnabled; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GuestsUpdateRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GuestsUpdateRequest.java index 6e98937..a4527e7 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GuestsUpdateRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/GuestsUpdateRequest.java @@ -2,7 +2,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import java.util.List; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class GuestsUpdateRequest { - @NotNull public List ids; + @NotNull private List ids; } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/InitPasswordResetRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/InitPasswordResetRequest.java index d82c4f0..dca0d79 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/InitPasswordResetRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/InitPasswordResetRequest.java @@ -3,8 +3,10 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.Email; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.Pattern; +import lombok.Data; /** DTO for password reset request */ +@Data public class InitPasswordResetRequest { /** * The user's email (validated according to criteria used in >input type="email"<> @@ -14,12 +16,4 @@ public class InitPasswordResetRequest { @Email(message = "Please provide a valid email address") @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") private String email; - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/JWTRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/JWTRequest.java index da11bc3..48bb386 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/JWTRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/JWTRequest.java @@ -1,36 +1,10 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class JWTRequest { @NotNull private String usernameOrEmail; @NotNull private String password; - - public String getUsernameOrEmail() { - return this.usernameOrEmail; - } - - public void setUsernameOrEmail(String usernameOrEmail) { - this.usernameOrEmail = usernameOrEmail; - } - - public String getPassword() { - return this.password; - } - - public void setPassword(String password) { - this.password = password; - } - - @Override - public String toString() { - return "JWTRequest{" - + "usernameOrEmail='" - + usernameOrEmail - + '\'' - + ", password='" - + password - + '\'' - + '}'; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/JWTResponse.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/JWTResponse.java index 7bc04f2..bf47cc3 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/JWTResponse.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/JWTResponse.java @@ -1,13 +1,10 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor public class JWTResponse { private final String jwttoken; - - public JWTResponse(String jwttoken) { - this.jwttoken = jwttoken; - } - - public String getToken() { - return this.jwttoken; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/KnobDimmerDimRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/KnobDimmerDimRequest.java index 6df303a..d0a45c8 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/KnobDimmerDimRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/KnobDimmerDimRequest.java @@ -3,7 +3,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class KnobDimmerDimRequest { /** The device id */ @@ -14,20 +16,4 @@ public class KnobDimmerDimRequest { @Min(0) @Max(100) private Integer intensity; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Integer getIntensity() { - return intensity; - } - - public void setIntensity(Integer intensity) { - this.intensity = intensity; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/PasswordResetRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/PasswordResetRequest.java index bf5bccf..871b95c 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/PasswordResetRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/PasswordResetRequest.java @@ -1,8 +1,10 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.*; +import lombok.Data; /** DTO for password reset request */ +@Data public class PasswordResetRequest { @NotNull private String confirmationToken; @@ -15,20 +17,4 @@ public class PasswordResetRequest { max = 255, message = "Your password should be at least 6 characters long and up to 255 chars long") private String password; - - public String getConfirmationToken() { - return confirmationToken; - } - - public void setConfirmationToken(String confirmationToken) { - this.confirmationToken = confirmationToken; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeTriggerSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeTriggerSaveRequest.java index 567c035..0df49a5 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeTriggerSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeTriggerSaveRequest.java @@ -2,7 +2,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.RangeTrigger; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class RangeTriggerSaveRequest { private long id; @@ -14,44 +16,4 @@ public class RangeTriggerSaveRequest { @NotNull private RangeTrigger.Operator operator; @NotNull private double range; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public Long getDeviceId() { - return deviceId; - } - - public void setDeviceId(Long deviceId) { - this.deviceId = deviceId; - } - - public Long getAutomationId() { - return automationId; - } - - public void setAutomationId(Long automationId) { - this.automationId = automationId; - } - - public RangeTrigger.Operator getOperator() { - return operator; - } - - public void setOperator(RangeTrigger.Operator operator) { - this.operator = operator; - } - - public double getRange() { - return range; - } - - public void setRange(Double range) { - this.range = range; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RoomSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RoomSaveRequest.java index cf362ac..a4074ab 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RoomSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RoomSaveRequest.java @@ -3,7 +3,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Icon; import javax.persistence.Lob; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class RoomSaveRequest { /** Room identifier */ @@ -21,36 +23,4 @@ public class RoomSaveRequest { /** The user given name of this room (e.g. 'Master bedroom') */ @NotNull private String name; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Icon getIcon() { - return icon; - } - - public void setIcon(Icon icon) { - this.icon = icon; - } - - public String getImage() { - return image; - } - - public void setImage(String image) { - this.image = image; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ScenePrioritySaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ScenePrioritySaveRequest.java index 14a1873..6f5236b 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ScenePrioritySaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ScenePrioritySaveRequest.java @@ -2,7 +2,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class ScenePrioritySaveRequest { @NotNull private Long automationId; @@ -11,28 +13,4 @@ public class ScenePrioritySaveRequest { private Integer priority; @NotNull private Long sceneId; - - public Long getAutomationId() { - return automationId; - } - - public void setAutomationId(Long automationId) { - this.automationId = automationId; - } - - public Integer getPriority() { - return priority; - } - - public void setPriority(Integer priority) { - this.priority = priority; - } - - public Long getSceneId() { - return sceneId; - } - - public void setSceneId(Long sceneId) { - this.sceneId = sceneId; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SceneSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SceneSaveRequest.java index b890536..59e1b2f 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SceneSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SceneSaveRequest.java @@ -3,7 +3,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Icon; import javax.persistence.Column; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class SceneSaveRequest { /** Room identifier */ @@ -16,32 +18,4 @@ public class SceneSaveRequest { /** Determines whether a guest can access this scene */ @Column @NotNull private boolean guestAccessEnabled; - - public boolean isGuestAccessEnabled() { - return guestAccessEnabled; - } - - public void setGuestAccessEnabled(boolean guestAccessEnabled) { - this.guestAccessEnabled = guestAccessEnabled; - } - - public long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Icon getIcon() { - return icon; - } - - public void setIcon(Icon icon) { - this.icon = icon; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequest.java index 62b0b5e..8566bde 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SensorSaveRequest.java @@ -1,29 +1,14 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Sensor; -import com.google.gson.annotations.SerializedName; import java.math.BigDecimal; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class SensorSaveRequest { - - /** Type of sensor, i.e. of the thing the sensor measures. */ - public enum SensorType { - /** A sensor that measures temperature in degrees celsius */ - @SerializedName("TEMPERATURE") - TEMPERATURE, - - /** A sensor that measures relative humidity in percentage points */ - @SerializedName("HUMIDITY") - HUMIDITY, - - /** A sensor that measures light in degrees */ - @SerializedName("LIGHT") - LIGHT - } - /** The type of this sensor */ @NotNull @Enumerated(value = EnumType.STRING) @@ -39,36 +24,4 @@ public class SensorSaveRequest { /** The name of the device as assigned by the user (e.g. 'Master bedroom light') */ @NotNull private String name; - - public void setRoomId(Long roomId) { - this.roomId = roomId; - } - - public void setName(String name) { - this.name = name; - } - - public Long getRoomId() { - return roomId; - } - - public String getName() { - return name; - } - - public Sensor.SensorType getSensor() { - return sensor; - } - - public void setSensor(Sensor.SensorType sensor) { - this.sensor = sensor; - } - - public BigDecimal getValue() { - return value; - } - - public void setValue(BigDecimal value) { - this.value = value; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchOperationRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchOperationRequest.java index 3fb552b..fa1aed5 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchOperationRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchOperationRequest.java @@ -1,8 +1,10 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.NotNull; +import lombok.Data; /** An on/off/toggle operation on a switch */ +@Data public class SwitchOperationRequest { /** The device id */ @@ -16,20 +18,4 @@ public class SwitchOperationRequest { /** The type of switch operation */ @NotNull private SwitchOperationRequest.OperationType type; - - public OperationType getType() { - return type; - } - - public void setType(OperationType type) { - this.type = type; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchableSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchableSaveRequest.java index 16caaed..b2ab2fb 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchableSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchableSaveRequest.java @@ -1,7 +1,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class SwitchableSaveRequest { /** The state of this switch */ private boolean on; @@ -17,36 +19,4 @@ public class SwitchableSaveRequest { /** The name of the device as assigned by the user (e.g. 'Master bedroom light') */ @NotNull private String name; - - public void setRoomId(Long roomId) { - this.roomId = roomId; - } - - public void setName(String name) { - this.name = name; - } - - public long getId() { - return id; - } - - public Long getRoomId() { - return roomId; - } - - public String getName() { - return name; - } - - public boolean isOn() { - return on; - } - - public void setOn(boolean on) { - this.on = on; - } - - public void setId(long id) { - this.id = id; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchableStateSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchableStateSaveRequest.java index ab03f27..7a29c02 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchableStateSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/SwitchableStateSaveRequest.java @@ -1,23 +1,13 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class SwitchableStateSaveRequest { /** Device id (used only for update requests) */ @NotNull private Long id; @NotNull private boolean on; - - public boolean isOn() { - return on; - } - - public void setOn(boolean on) { - this.on = on; - } - - public Long getId() { - return id; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatSaveRequest.java index 5ac3402..6bbfbb8 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatSaveRequest.java @@ -2,7 +2,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import java.math.BigDecimal; import javax.validation.constraints.NotNull; +import lombok.Data; +@Data public class ThermostatSaveRequest { /** Device identifier */ @@ -24,52 +26,4 @@ public class ThermostatSaveRequest { /** State of this thermostat */ @NotNull private boolean turnOn; - - public boolean isTurnOn() { - return turnOn; - } - - public void setTurnOn(boolean turnOn) { - this.turnOn = turnOn; - } - - public boolean isUseExternalSensors() { - return useExternalSensors; - } - - public void setUseExternalSensors(boolean useExternalSensors) { - this.useExternalSensors = useExternalSensors; - } - - public BigDecimal getTargetTemperature() { - return this.targetTemperature; - } - - public void setTargetTemperature(BigDecimal targetTemperature) { - this.targetTemperature = targetTemperature; - } - - public void setRoomId(Long roomId) { - this.roomId = roomId; - } - - public void setName(String name) { - this.name = name; - } - - public long getId() { - return id; - } - - public Long getRoomId() { - return roomId; - } - - public String getName() { - return name; - } - - public void setId(long id) { - this.id = id; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserRegistrationRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserRegistrationRequest.java index 785d408..bf1caa5 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserRegistrationRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserRegistrationRequest.java @@ -1,7 +1,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import javax.validation.constraints.*; +import lombok.Data; +@Data public class UserRegistrationRequest { /** The full name of the user */ @@ -35,36 +37,4 @@ public class UserRegistrationRequest { @Email(message = "Please provide a valid email address") @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") private String email; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserResponse.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserResponse.java index 86314a0..3cc0910 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserResponse.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserResponse.java @@ -1,14 +1,14 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.User; +import lombok.Data; +@Data public class UserResponse { private Long id; private String username; private String name; - private UserResponse() {} - public static UserResponse fromUser(User u) { final UserResponse us = new UserResponse(); us.name = u.getName(); @@ -16,16 +16,4 @@ public class UserResponse { us.username = u.getUsername(); return us; } - - public Long getId() { - return id; - } - - public String getUsername() { - return username; - } - - public String getName() { - return name; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserUpdateRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserUpdateRequest.java deleted file mode 100644 index 551b84a..0000000 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/UserUpdateRequest.java +++ /dev/null @@ -1,48 +0,0 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; - -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; - -public class UserUpdateRequest { - /** The full name of the user */ - @NotEmpty(message = "Please provide a full name") - private String name; - - /** A non-salted password */ - @NotEmpty(message = "Please provide a password") - private String password; - - /** - * The user's email (validated according to criteria used in >input type="email"<> - * , technically not RFC 5322 compliant - */ - @NotEmpty(message = "Please provide an email") - @Email(message = "Please provide a valid email address") - @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") - private String email; - - public String getName() { - return name; - } - - public String getPassword() { - return password; - } - - public String getEmail() { - return email; - } - - public void setName(String name) { - this.name = name; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setEmail(String email) { - this.email = email; - } -}