Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce lombok to models #117

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/telraam/database/daos/StationDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface StationDAO extends DAO<Station> {
List<Station> getAll();

@Override
@SqlUpdate("INSERT INTO station (name, distance_from_start, broken, url, coord_x, coord_y) VALUES (:name, :distanceFromStart, :isBroken, :url, :coordX, :coordY)")
@SqlUpdate("INSERT INTO station (name, distance_from_start, broken, url, coord_x, coord_y) VALUES (:name, :distanceFromStart, :broken, :url, :coordX, :coordY)")
@GetGeneratedKeys({"id"})
int insert(@BindBean Station station);

Expand All @@ -33,6 +33,6 @@ public interface StationDAO extends DAO<Station> {
int deleteById(@Bind("id") int id);

@Override
@SqlUpdate("UPDATE station SET name = :name, distance_from_start = :distanceFromStart, broken = :isBroken, url = :url, coord_x = :coordX, coord_y = :coordY WHERE id = :id")
@SqlUpdate("UPDATE station SET name = :name, distance_from_start = :distanceFromStart, broken = :broken, url = :url, coord_x = :coordX, coord_y = :coordY WHERE id = :id")
int update(@Bind("id") int id, @BindBean Station station);
}
33 changes: 5 additions & 28 deletions src/main/java/telraam/database/models/Baton.java
Original file line number Diff line number Diff line change
@@ -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() {
}
Comment on lines -10 to -12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can this not be removed, and why did u remove it 😅
Maybe keep this comment if we found out what it is for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed it because it is replaced with the @NoArgsConstructor. It think JDBI needs it to create the object after fetching it from the DB (and then changes the values via setters)


public Baton(String name) {
this.name = name;
}
Expand All @@ -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;
Expand Down
49 changes: 5 additions & 44 deletions src/main/java/telraam/database/models/BatonSwitchover.java
Original file line number Diff line number Diff line change
@@ -1,66 +1,27 @@
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;
private Integer previousBatonId;
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;
this.newBatonId = newBatonId;
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;
Expand Down
88 changes: 5 additions & 83 deletions src/main/java/telraam/database/models/Detection.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
}
48 changes: 5 additions & 43 deletions src/main/java/telraam/database/models/Lap.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}
25 changes: 5 additions & 20 deletions src/main/java/telraam/database/models/LapSource.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading
Loading