You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2019/09/07 16:36:00 UTC

[GitHub] [httpcomponents-core] ok2c commented on a change in pull request #147: Time values

ok2c commented on a change in pull request #147: Time values
URL: https://github.com/apache/httpcomponents-core/pull/147#discussion_r321975400
 
 

 ##########
 File path: httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
 ##########
 @@ -371,13 +347,43 @@ public int toSecondsIntBound() {
         return asBoundInt(toSeconds());
     }
 
+    public Timeout toTimeout() {
+        return Timeout.of(duration, timeUnit);
+    }
+
     @Override
-    public String toString() {
-        return String.format(Locale.ROOT, "%,d %s", duration, timeUnit);
+    public int compareTo(final TimeValue other) {
+        if (other != null) {
+            final TimeUnit targetTimeUnit = min(other.getTimeUnit());
+            return Long.compare(convert(targetTimeUnit), other.convert(targetTimeUnit));
+        } else {
+            return -Integer.MAX_VALUE;
+        }
     }
 
-    public Timeout toTimeout() {
-        return Timeout.of(duration, timeUnit);
+    @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() {
 
 Review comment:
   @michael-o For the sake of consistency with the rest of code base, though I am open to the idea of dropping our `LangUtils` in favor to `Objects`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org