Skip to content

Commit

Permalink
Use lombok to generate override implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpbauer committed Nov 23, 2022
1 parent 6f8e7d2 commit ab86c33
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package org.sakaiproject.attendance.api.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
import lombok.ToString;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Type;
Expand All @@ -30,7 +30,6 @@
import java.io.Serializable;
import java.time.Instant;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
Expand All @@ -43,8 +42,9 @@
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "ATTENDANCE_EVENT_T")
@Getter
@Setter
@Data
@ToString(exclude = {"attendanceSite", "records"})
@EqualsAndHashCode(of = "id")
@NoArgsConstructor
@AllArgsConstructor
public class AttendanceEvent implements Serializable, PersistableEntity<Long> {
Expand Down Expand Up @@ -76,25 +76,4 @@ public AttendanceEvent(AttendanceEvent attendanceEvent) {
this.startDateTime = attendanceEvent.startDateTime;
this.attendanceSite = attendanceEvent.attendanceSite;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
AttendanceEvent that = (AttendanceEvent) o;
return id != null && Objects.equals(id, that.id);
}

@Override
public int hashCode() {
return getClass().hashCode();
}

@Override
public String toString() {
return getClass().getSimpleName() + "(" +
"id = " + id + ", " +
"name = " + name + ", " +
"startDateTime = " + startDateTime + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
package org.sakaiproject.attendance.api.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
import lombok.ToString;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.sakaiproject.springframework.data.PersistableEntity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
* The AttendanceGrade earned for the all AttendanceItems
Expand All @@ -39,8 +38,9 @@
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "ATTENDANCE_GRADE_T")
@Getter
@Setter
@Data
@ToString(exclude = {"attendanceSite"})
@EqualsAndHashCode(of = "id")
@NoArgsConstructor
@AllArgsConstructor
public class AttendanceGrade implements Serializable, PersistableEntity<Long> {
Expand Down Expand Up @@ -69,26 +69,4 @@ public AttendanceGrade(AttendanceSite aS, String userId) {
this.attendanceSite = aS;
this.userID = userId;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
AttendanceGrade that = (AttendanceGrade) o;
return id != null && Objects.equals(id, that.id);
}

@Override
public int hashCode() {
return getClass().hashCode();
}

@Override
public String toString() {
return getClass().getSimpleName() + "(" +
"id = " + id + ", " +
"grade = " + grade + ", " +
"userID = " + userID + ", " +
"override = " + override + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
package org.sakaiproject.attendance.api.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
import lombok.ToString;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.sakaiproject.springframework.data.PersistableEntity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
* An AttendanceRecord for a specific user for a specific AttendanceEvent
Expand All @@ -43,8 +42,9 @@
@Index(name = "ATTEN_EVENT_STATUS_I", columnList = "A_EVENT_ID, STATUS"),
@Index(name = "ATTEN_EVENT_USER_STATUS_I", columnList = "A_EVENT_ID, USER_ID, STATUS")
})
@Getter
@Setter
@Data
@ToString(exclude = {"attendanceEvent"})
@EqualsAndHashCode(of = "id")
@NoArgsConstructor
@AllArgsConstructor
public class AttendanceRecord implements Serializable, PersistableEntity<Long> {
Expand Down Expand Up @@ -76,26 +76,4 @@ public AttendanceRecord(AttendanceEvent e, String uId, Status s) {
this.userID = uId;
this.status = s;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
AttendanceRecord that = (AttendanceRecord) o;
return id != null && Objects.equals(id, that.id);
}

@Override
public int hashCode() {
return getClass().hashCode();
}

@Override
public String toString() {
return getClass().getSimpleName() + "(" +
"id = " + id + ", " +
"userID = " + userID + ", " +
"status = " + status + ", " +
"comment = " + comment + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package org.sakaiproject.attendance.api.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
import lombok.ToString;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.sakaiproject.attendance.api.util.AttendanceConstants;
Expand All @@ -29,7 +29,6 @@
import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
Expand All @@ -43,8 +42,9 @@
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "ATTENDANCE_SITE_T")
@Getter
@Setter
@Data
@ToString
@EqualsAndHashCode(of = "id")
@NoArgsConstructor
@AllArgsConstructor
public class AttendanceSite implements Serializable, PersistableEntity<Long> {
Expand Down Expand Up @@ -91,17 +91,4 @@ public AttendanceSite(String siteID) {
this.siteID = siteID;
this.gradebookItemName = AttendanceConstants.GRADEBOOK_ITEM_NAME;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
AttendanceSite that = (AttendanceSite) o;
return id != null && Objects.equals(id, that.id);
}

@Override
public int hashCode() {
return getClass().hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
package org.sakaiproject.attendance.api.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
import lombok.ToString;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.sakaiproject.springframework.data.PersistableEntity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
* An AttendanceStatus is a wrapper around the Status enum type defining meta information on individual Statuses.
Expand All @@ -38,8 +37,9 @@
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "ATTENDANCE_STATUS_T")
@Getter
@Setter
@Data
@ToString(exclude = {"attendanceSite"})
@EqualsAndHashCode(of = "id")
@NoArgsConstructor
@AllArgsConstructor
public class AttendanceStatus implements Serializable, PersistableEntity<Long> {
Expand Down Expand Up @@ -72,17 +72,4 @@ public AttendanceStatus(AttendanceStatus attendanceStatus) {
this.sortOrder = attendanceStatus.getSortOrder();
this.attendanceSite = attendanceStatus.getAttendanceSite();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
AttendanceStatus that = (AttendanceStatus) o;
return id != null && Objects.equals(id, that.id);
}

@Override
public int hashCode() {
return getClass().hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@

package org.sakaiproject.attendance.api.model;

import lombok.Getter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.Hibernate;
import lombok.ToString;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.sakaiproject.springframework.data.PersistableEntity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
* @author David P. Bauer [dbauer1 (at) udayton (dot) edu]
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name = "ATTENDANCE_RULE_T")
@Getter
@Setter
@Data
@ToString(exclude = {"attendanceSite", "records"})
@EqualsAndHashCode(of = "id")
@NoArgsConstructor
public class GradingRule implements Serializable, PersistableEntity<Long> {
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -66,17 +66,4 @@ public class GradingRule implements Serializable, PersistableEntity<Long> {
public GradingRule(AttendanceSite attendanceSite) {
this.attendanceSite = attendanceSite;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
GradingRule that = (GradingRule) o;
return id != null && Objects.equals(id, that.id);
}

@Override
public int hashCode() {
return getClass().hashCode();
}
}
Loading

0 comments on commit ab86c33

Please sign in to comment.