summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2017-03-17 19:28:59 -0400
committerbjculkin <bjculkin@mix.wvu.edu>2017-03-17 19:28:59 -0400
commit5832ef0286430d04484b70d49c73e081a80ec9c7 (patch)
tree04ab56561978c14415f71b934f7d8a3aaa1a037e /BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
parentc8593896ba0d93c9512a71c2e70d1d503627b1b0 (diff)
Add more toString/hashCode/equals
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/Pair.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/Pair.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java b/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
index 77afa4a..48d3aca 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
@@ -100,4 +100,32 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> {
public String toString() {
return "pair[l=" + leftValue.toString() + ", r=" + rightValue.toString() + "]";
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((leftValue == null) ? 0 : leftValue.hashCode());
+ result = prime * result + ((rightValue == null) ? 0 : rightValue.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(this == obj) return true;
+ if(obj == null) return false;
+ if(getClass() != obj.getClass()) return false;
+
+ Pair<?, ?> other = (Pair<?, ?>) obj;
+
+ if(leftValue == null) {
+ if(other.leftValue != null) return false;
+ } else if(!leftValue.equals(other.leftValue)) return false;
+
+ if(rightValue == null) {
+ if(other.rightValue != null) return false;
+ } else if(!rightValue.equals(other.rightValue)) return false;
+
+ return true;
+ }
}