You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/04/14 11:14:17 UTC

svn commit: r1791354 - /httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java

Author: olegk
Date: Fri Apr 14 11:14:17 2017
New Revision: 1791354

URL: http://svn.apache.org/viewvc?rev=1791354&view=rev
Log:
Added #hasCode and #equals to TimeValue

Modified:
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java?rev=1791354&r1=1791353&r2=1791354&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java Fri Apr 14 11:14:17 2017
@@ -161,6 +161,27 @@ public class TimeValue {
     }
 
     @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof TimeValue) {
+            final TimeValue that = (TimeValue) obj;
+            return this.duration == that.duration &&
+                    LangUtils.equals(this.timeUnit, that.timeUnit);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = LangUtils.HASH_SEED;
+        hash = LangUtils.hashCode(hash, duration);
+        hash = LangUtils.hashCode(hash, timeUnit);
+        return hash;
+    }
+
+    @Override
     public String toString() {
         return String.format("%,d %s", Long.valueOf(duration), timeUnit);
     }