Add reasonable hashCode(), equals() and toString() methods
git-svn-id: https://svn.apache.org/repos/asf/turbine/core/trunk@1885147 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/java/org/apache/turbine/util/uri/URIParam.java b/src/java/org/apache/turbine/util/uri/URIParam.java
index 8acd8ac..570e99d 100644
--- a/src/java/org/apache/turbine/util/uri/URIParam.java
+++ b/src/java/org/apache/turbine/util/uri/URIParam.java
@@ -1,6 +1,5 @@
package org.apache.turbine.util.uri;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -20,6 +19,7 @@
* under the License.
*/
+import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
@@ -73,4 +73,40 @@
{
return value;
}
+
+ /**
+ * Calculate hash code based on field values
+ */
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(key, value);
+ }
+
+ /**
+ * Calculate equality based on field values
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ URIParam other = (URIParam) obj;
+
+ return Objects.equals(getKey(), other.getKey()) ||
+ Objects.equals(getValue(), other.getValue());
+ }
+
+ /**
+ * Provide a string representation of the object
+ */
+ @Override
+ public String toString()
+ {
+ return "URIParam [key=" + key + ", value=" + value + "]";
+ }
}