From 4cf2ac1d886a3f2e10ceac22b850f37fa8aeb2b8 Mon Sep 17 00:00:00 2001 From: Markus Kreth Date: Fri, 11 Sep 2020 00:27:11 +0200 Subject: [PATCH] formatting and refactoring --- .../controller/AttendanceController.java | 10 -- .../model/data/CompetitionType.java | 170 +++++++++--------- 2 files changed, 85 insertions(+), 95 deletions(-) diff --git a/src/main/java/de/kreth/clubhelper/model/controller/AttendanceController.java b/src/main/java/de/kreth/clubhelper/model/controller/AttendanceController.java index 29ebf04..be1b88e 100644 --- a/src/main/java/de/kreth/clubhelper/model/controller/AttendanceController.java +++ b/src/main/java/de/kreth/clubhelper/model/controller/AttendanceController.java @@ -17,9 +17,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - import de.kreth.clubhelper.model.dao.AttendanceDao; import de.kreth.clubhelper.model.dao.PersonDao; import de.kreth.clubhelper.model.data.Attendance; @@ -40,13 +37,6 @@ public class AttendanceController { @ResponseBody public List getAttendencesOn(@PathVariable("date") @DateTimeFormat(iso = ISO.DATE) LocalDate date) { List findByOnDate = attendanceDao.findByOnDate(date); - ObjectMapper mapper = new ObjectMapper(); - try { - String one = mapper.writeValueAsString(findByOnDate.get(0)); - System.out.println(one); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } return findByOnDate; } diff --git a/src/main/java/de/kreth/clubhelper/model/data/CompetitionType.java b/src/main/java/de/kreth/clubhelper/model/data/CompetitionType.java index 967f8b0..4c61525 100644 --- a/src/main/java/de/kreth/clubhelper/model/data/CompetitionType.java +++ b/src/main/java/de/kreth/clubhelper/model/data/CompetitionType.java @@ -14,95 +14,95 @@ import javax.persistence.Table; @Table(name = "clubevent_addon") public class CompetitionType implements Serializable { - @Id - private String id; - - @Column(name = "competition_type", nullable = false, length = 45) - private String type; - - @OneToOne(mappedBy = "competitionType") - @JoinColumn(name = "id") - @MapsId - private ClubEvent clubEvent; - - public Type getType() { - return Type.valueOf(type); - } - - public void setType(Type type) { - this.type = type.name(); - } - - public void setClubEvent(ClubEvent clubEvent) { - this.clubEvent = clubEvent; - } - - public String getId() { - return id; + private static final long serialVersionUID = 1L; + + @Id + private String id; + + @Column(name = "competition_type", nullable = false, length = 45) + private String type; + + @OneToOne(mappedBy = "competitionType") + @JoinColumn(name = "id") + @MapsId + private ClubEvent clubEvent; + + public Type getType() { + return Type.valueOf(type); + } + + public void setType(Type type) { + this.type = type.name(); + } + + public void setClubEvent(ClubEvent clubEvent) { + this.clubEvent = clubEvent; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ClubEvent getClubEvent() { + return clubEvent; + } + + public void setType(String type) { + this.type = type; + } + + public static enum Type { + EINZEL, + SYNCHRON, + DOPPELMINI, + MANNSCHAFT, + LIGA + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; } - - public void setId(String id) { - this.id = id; + if (obj == null) { + return false; } - - public ClubEvent getClubEvent() { - return clubEvent; + if (getClass() != obj.getClass()) { + return false; } - - public void setType(String type) { - this.type = type; + CompetitionType other = (CompetitionType) obj; + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; } - - public static enum Type { - EINZEL, - SYNCHRON, - DOPPELMINI, - MANNSCHAFT, - LIGA + if (type == null) { + if (other.type != null) { + return false; + } + } else if (!type.equals(other.type)) { + return false; } + return true; + } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - CompetitionType other = (CompetitionType) obj; - if (id == null) { - if (other.id != null) { - return false; - } - } - else if (!id.equals(other.id)) { - return false; - } - if (type == null) { - if (other.type != null) { - return false; - } - } - else if (!type.equals(other.type)) { - return false; - } - return true; - } - - @Override - public String toString() { - return type; - } + @Override + public String toString() { + return type; + } }