diff --git a/build.gradle b/build.gradle index d1a3b42..db65596 100644 --- a/build.gradle +++ b/build.gradle @@ -74,6 +74,13 @@ dependencies { // Swagger-UI implementation 'com.smoketurner:dropwizard-swagger:2.0.0-1' + + // Getter & Setter via annotations + compileOnly 'org.projectlombok:lombok:1.18.32' + annotationProcessor 'org.projectlombok:lombok:1.18.32' + + testCompileOnly 'org.projectlombok:lombok:1.18.32' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.32' } test { diff --git a/src/main/java/telraam/database/models/Baton.java b/src/main/java/telraam/database/models/Baton.java index 525b95b..f5889c0 100644 --- a/src/main/java/telraam/database/models/Baton.java +++ b/src/main/java/telraam/database/models/Baton.java @@ -1,16 +1,17 @@ package telraam.database.models; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + import java.util.Objects; +@Getter @Setter @NoArgsConstructor public class Baton { private Integer id; private String name; private String mac; - // DO NOT REMOVE - public Baton() { - } - public Baton(String name) { this.name = name; } @@ -20,30 +21,6 @@ public Baton(String name, String mac) { this.mac = mac; } - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getMac() { - return mac; - } - - public void setMac(String mac) { - this.mac = mac; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/telraam/database/models/BatonSwitchover.java b/src/main/java/telraam/database/models/BatonSwitchover.java index 358446e..d888870 100644 --- a/src/main/java/telraam/database/models/BatonSwitchover.java +++ b/src/main/java/telraam/database/models/BatonSwitchover.java @@ -1,8 +1,13 @@ package telraam.database.models; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + import java.sql.Timestamp; import java.util.Objects; +@Getter @Setter @NoArgsConstructor public class BatonSwitchover { private Integer id; private Integer teamId; @@ -10,10 +15,6 @@ public class BatonSwitchover { private Integer newBatonId; private Timestamp timestamp; - // DO NOT REMOVE - public BatonSwitchover() { - } - public BatonSwitchover(Integer teamId, Integer previousBatonId, Integer newBatonId, Timestamp timestamp) { this.teamId = teamId; this.previousBatonId = previousBatonId; @@ -21,46 +22,6 @@ public BatonSwitchover(Integer teamId, Integer previousBatonId, Integer newBaton this.timestamp = timestamp; } - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getTeamId() { - return teamId; - } - - public void setTeamId(Integer teamId) { - this.teamId = teamId; - } - - public Integer getPreviousBatonId() { - return previousBatonId; - } - - public void setPreviousBatonId(Integer previousBatonId) { - this.previousBatonId = previousBatonId; - } - - public Integer getNewBatonId() { - return newBatonId; - } - - public void setNewBatonId(Integer newBatonId) { - this.newBatonId = newBatonId; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = timestamp; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/telraam/database/models/Detection.java b/src/main/java/telraam/database/models/Detection.java index 6a7c916..23a4067 100644 --- a/src/main/java/telraam/database/models/Detection.java +++ b/src/main/java/telraam/database/models/Detection.java @@ -1,7 +1,12 @@ package telraam.database.models; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + import java.sql.Timestamp; +@Setter @Getter @NoArgsConstructor public class Detection { private Integer id; private Integer batonId; @@ -14,9 +19,6 @@ public class Detection { private Timestamp timestampIngestion; private Integer teamId; - public Detection() { - } - public Detection(Integer batonId, Integer stationId, Integer rssi, Float battery, Long uptimeMs, Integer remoteId, Timestamp timestamp, Timestamp timestampIngestion) { this.batonId = batonId; this.stationId = stationId; @@ -27,84 +29,4 @@ public Detection(Integer batonId, Integer stationId, Integer rssi, Float battery this.timestamp = timestamp; this.timestampIngestion = timestampIngestion; } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getBatonId() { - return batonId; - } - - public void setBatonId(Integer batonId) { - this.batonId = batonId; - } - - public Integer getStationId() { - return stationId; - } - - public void setStationId(Integer stationId) { - this.stationId = stationId; - } - - public Integer getRssi() { - return rssi; - } - - public void setRssi(Integer rssi) { - this.rssi = rssi; - } - - public Float getBattery() { - return battery; - } - - public void setBattery(Float battery) { - this.battery = battery; - } - - public Long getUptimeMs() { - return uptimeMs; - } - - public void setUptimeMs(Long uptimeMs) { - this.uptimeMs = uptimeMs; - } - - public Integer getRemoteId() { - return remoteId; - } - - public void setRemoteId(Integer remoteId) { - this.remoteId = remoteId; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = timestamp; - } - - public Timestamp getTimestampIngestion() { - return timestampIngestion; - } - - public void setTimestampIngestion(Timestamp timestampIngestion) { - this.timestampIngestion = timestampIngestion; - } - - public Integer getTeamId() { - return teamId; - } - - public void setTeamId(Integer teamId) { - this.teamId = teamId; - } } diff --git a/src/main/java/telraam/database/models/Lap.java b/src/main/java/telraam/database/models/Lap.java index f084c9c..7573562 100644 --- a/src/main/java/telraam/database/models/Lap.java +++ b/src/main/java/telraam/database/models/Lap.java @@ -1,7 +1,12 @@ package telraam.database.models; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + import java.sql.Timestamp; +@Getter @Setter @NoArgsConstructor public class Lap { private Integer id; private Integer teamId; @@ -10,52 +15,9 @@ public class Lap { private Boolean manual; private Timestamp timestamp; - public Lap() { - } - public Lap(Integer teamId, Integer lapSourceId, Timestamp timestamp) { this.teamId = teamId; this.lapSourceId = lapSourceId; this.timestamp = timestamp; } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getTeamId() { - return teamId; - } - - public void setTeamId(Integer teamId) { - this.teamId = teamId; - } - - public Integer getLapSourceId() { - return lapSourceId; - } - - public void setLapSourceId(Integer lapSourceId) { - this.lapSourceId = lapSourceId; - } - - public Boolean getManual() { - return manual; - } - - public void setManual(Boolean manual) { - this.manual = manual; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = timestamp; - } } diff --git a/src/main/java/telraam/database/models/LapSource.java b/src/main/java/telraam/database/models/LapSource.java index 82ff02f..aa39fa3 100644 --- a/src/main/java/telraam/database/models/LapSource.java +++ b/src/main/java/telraam/database/models/LapSource.java @@ -1,33 +1,18 @@ package telraam.database.models; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + /** * The lap source tells you where the lap comes from. */ +@Getter @Setter @NoArgsConstructor public class LapSource { private Integer id; private String name; - public LapSource() { - - } - public LapSource(String name) { this.name = name; } - - public Integer getId() { - return id; - } - - public String getName() { - return name; - } - - public void setId(Integer id) { - this.id = id; - } - - public void setName(String name) { - this.name = name; - } } diff --git a/src/main/java/telraam/database/models/LapSourceSwitchover.java b/src/main/java/telraam/database/models/LapSourceSwitchover.java index ceef17d..4b3a445 100644 --- a/src/main/java/telraam/database/models/LapSourceSwitchover.java +++ b/src/main/java/telraam/database/models/LapSourceSwitchover.java @@ -1,46 +1,23 @@ package telraam.database.models; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + import java.sql.Timestamp; import java.util.Objects; +@Getter @Setter @NoArgsConstructor public class LapSourceSwitchover { private Integer id; private Integer newLapSource; private Timestamp timestamp; - // DO NOT REMOVE - public LapSourceSwitchover() { - } - public LapSourceSwitchover(Integer newLapSource, Timestamp timestamp) { this.newLapSource = newLapSource; this.timestamp = timestamp; } - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getNewLapSource() { - return newLapSource; - } - - public void setNewLapSource(Integer newLapSource) { - this.newLapSource = newLapSource; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = timestamp; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/telraam/database/models/Station.java b/src/main/java/telraam/database/models/Station.java index b84d338..fa55451 100644 --- a/src/main/java/telraam/database/models/Station.java +++ b/src/main/java/telraam/database/models/Station.java @@ -1,5 +1,9 @@ package telraam.database.models; +import lombok.Getter; +import lombok.Setter; + +@Getter @Setter public class Station { private Integer id; private String name; @@ -31,61 +35,11 @@ public Station(String name, boolean isBroken) { this.isBroken = isBroken; } - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Double getDistanceFromStart() { - return distanceFromStart; - } - - public void setDistanceFromStart(Double distanceFromStart) { - this.distanceFromStart = distanceFromStart; - } - - public Boolean getIsBroken() { - return isBroken; - } - - public void setBroken(Boolean isBroken) { + // These are overridden, otherwise the updateDoesUpdate test fails for some reason? + public void setIsBroken(boolean isBroken) { this.isBroken = isBroken; } - - public String getUrl() { - return this.url; - } - - public void setUrl(String url) { - this.url = url; - } - - public Double getCoordX() { - return this.coordX; - } - - ; - - public void setCoordX(Double coordX) { - this.coordX = coordX; - } - - public Double getCoordY() { - return this.coordY; - } - - public void setCoordY(Double coordY) { - this.coordY = coordY; + public void setBroken(boolean isBroken) { + this.isBroken = isBroken; } } diff --git a/src/main/java/telraam/database/models/Team.java b/src/main/java/telraam/database/models/Team.java index 3ed784e..94db208 100644 --- a/src/main/java/telraam/database/models/Team.java +++ b/src/main/java/telraam/database/models/Team.java @@ -1,13 +1,15 @@ package telraam.database.models; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter @Setter @NoArgsConstructor public class Team { private Integer id; private String name; private Integer batonId; - public Team() { - } - public Team(String name) { this.name = name; } @@ -16,28 +18,4 @@ public Team(String name, int batonId) { this.name = name; this.batonId = batonId; } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getBatonId() { - return batonId; - } - - public void setBatonId(Integer batonId) { - this.batonId = batonId; - } } diff --git a/src/main/java/telraam/database/models/TeamLapCount.java b/src/main/java/telraam/database/models/TeamLapCount.java index d7d3015..797c659 100644 --- a/src/main/java/telraam/database/models/TeamLapCount.java +++ b/src/main/java/telraam/database/models/TeamLapCount.java @@ -1,30 +1,12 @@ package telraam.database.models; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter @Setter @NoArgsConstructor @AllArgsConstructor public class TeamLapCount { private Integer lapSourceId; private Integer lapCount; - - public TeamLapCount() { - } - - public TeamLapCount(Integer lapTeamId, Integer lapCount) { - this.lapSourceId = lapTeamId; - this.lapCount = lapCount; - } - - public Integer getLapSourceId() { - return lapSourceId; - } - - public void setLapSourceId(Integer lapSourceId) { - this.lapSourceId = lapSourceId; - } - - public Integer getLapCount() { - return lapCount; - } - - public void setLapCount(Integer lapCount) { - this.lapCount = lapCount; - } } diff --git a/src/main/java/telraam/logic/simple/SimpleLapper.java b/src/main/java/telraam/logic/simple/SimpleLapper.java index 15c1265..9b26f9b 100644 --- a/src/main/java/telraam/logic/simple/SimpleLapper.java +++ b/src/main/java/telraam/logic/simple/SimpleLapper.java @@ -14,7 +14,7 @@ public class SimpleLapper implements Lapper { // Needs to be the same as in the lap_source database table. - static final String SOURCE_NAME = "simple-lapper"; + public static final String SOURCE_NAME = "simple-lapper"; private static final int MAX_SPEED = 50; private final LapSource source;