From c123c4a2dfe090d067d990331af3d80dd454efe4 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 19 Feb 2012 16:19:59 +0200 Subject: [PATCH] added toString() --- .../java/org/jclouds/util/Suppliers2.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/src/main/java/org/jclouds/util/Suppliers2.java b/core/src/main/java/org/jclouds/util/Suppliers2.java index 733dcf70d6..44cbb5f271 100644 --- a/core/src/main/java/org/jclouds/util/Suppliers2.java +++ b/core/src/main/java/org/jclouds/util/Suppliers2.java @@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; +import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; @@ -144,5 +145,28 @@ public class Suppliers2 { } private static final long serialVersionUID = 0; + + @Override + public int hashCode() { + return Objects.hashCode(delegate, durationNanos); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ExpiringMemoizingSupplier that = ExpiringMemoizingSupplier.class.cast(obj); + return Objects.equal(delegate, that.delegate) && Objects.equal(durationNanos, that.durationNanos); + } + + @Override + public String toString() { + return Objects.toStringHelper(this).add("delegate", delegate).add("durationNanos", durationNanos).toString(); + } + } }