From 3267138524e74ceb7c84dfdd0f2e390b2b42f082 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Sat, 22 Jun 2019 13:50:15 +0400 Subject: [PATCH] fix warnings --- .../java/ru/ulstu/core/model/BaseEntity.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main/java/ru/ulstu/core/model/BaseEntity.java b/src/main/java/ru/ulstu/core/model/BaseEntity.java index 6a68e91..4a61bb7 100644 --- a/src/main/java/ru/ulstu/core/model/BaseEntity.java +++ b/src/main/java/ru/ulstu/core/model/BaseEntity.java @@ -5,7 +5,9 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.MappedSuperclass; import javax.persistence.Version; +import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.util.Objects; @MappedSuperclass public abstract class BaseEntity implements Serializable, Comparable { @@ -16,14 +18,6 @@ public abstract class BaseEntity implements Serializable, Comparable { @Version private Integer version; - protected BaseEntity() { - } - - public BaseEntity(Integer id, Integer version) { - this.id = id; - this.version = version; - } - public Integer getId() { return id; } @@ -48,9 +42,7 @@ public abstract class BaseEntity implements Serializable, Comparable { return false; } BaseEntity other = (BaseEntity) obj; - if (id == null) { - return other.id == null; - } else return id.equals(other.id); + return Objects.equals(id, other.id); } @Override @@ -70,7 +62,7 @@ public abstract class BaseEntity implements Serializable, Comparable { } @Override - public int compareTo(Object o) { + public int compareTo(@NotNull Object o) { return id != null ? id.compareTo(((BaseEntity) o).getId()) : -1; }