fix warnings

This commit is contained in:
Anton Romanov 2019-06-22 13:50:15 +04:00
parent df1bf873ff
commit 3267138524

View File

@ -5,7 +5,9 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.persistence.Version; import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects;
@MappedSuperclass @MappedSuperclass
public abstract class BaseEntity implements Serializable, Comparable { public abstract class BaseEntity implements Serializable, Comparable {
@ -16,14 +18,6 @@ public abstract class BaseEntity implements Serializable, Comparable {
@Version @Version
private Integer version; private Integer version;
protected BaseEntity() {
}
public BaseEntity(Integer id, Integer version) {
this.id = id;
this.version = version;
}
public Integer getId() { public Integer getId() {
return id; return id;
} }
@ -48,9 +42,7 @@ public abstract class BaseEntity implements Serializable, Comparable {
return false; return false;
} }
BaseEntity other = (BaseEntity) obj; BaseEntity other = (BaseEntity) obj;
if (id == null) { return Objects.equals(id, other.id);
return other.id == null;
} else return id.equals(other.id);
} }
@Override @Override
@ -70,7 +62,7 @@ public abstract class BaseEntity implements Serializable, Comparable {
} }
@Override @Override
public int compareTo(Object o) { public int compareTo(@NotNull Object o) {
return id != null ? id.compareTo(((BaseEntity) o).getId()) : -1; return id != null ? id.compareTo(((BaseEntity) o).getId()) : -1;
} }