From: Benny Baumann Date: Sun, 7 Aug 2016 00:45:20 +0000 (+0200) Subject: fix: Implement both a null-pointer check and a hashCode function X-Git-Url: https://code.wpia.club/?p=gigi.git;a=commitdiff_plain;h=439aa2ac4560405a9abdb61fc35a74ba7c6538be fix: Implement both a null-pointer check and a hashCode function Change-Id: If22bdba6fc796223f63cc0a3684ae49d51c96a13 --- diff --git a/src/org/cacert/gigi/util/DayDate.java b/src/org/cacert/gigi/util/DayDate.java index 0b7ba383..a38e318c 100644 --- a/src/org/cacert/gigi/util/DayDate.java +++ b/src/org/cacert/gigi/util/DayDate.java @@ -58,12 +58,20 @@ public class DayDate { @Override public boolean equals(Object obj) { + if (null == obj) { + return false; + } if ( !(obj instanceof DayDate)) { throw new Error("You may not compare this date somthing other than a DayDate"); } return ((DayDate) obj).time == time; } + @Override + public int hashCode() { + return Long.hashCode(time); + } + public java.util.Date toDate() { return new java.util.Date(time); }