diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-17 09:57:54 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-17 09:57:54 -0400 |
| commit | 6ea2b6868eb496f39bbbfb2d13662cb397d4d799 (patch) | |
| tree | 343c6e0012e4c89bea75110171dafd08ad11d782 /BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java | |
| parent | 7f59d0b9de4536705b3122cb5a85d9c9f85846a3 (diff) | |
More toString/hashCode/equals
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java index 59df1b1..d19eed9 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java @@ -199,4 +199,32 @@ public class LazyPair<LeftType, RightType> implements IPair<LeftType, RightType> return sb.toString(); } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (leftMaterialized ? 1231 : 1237); + result = prime * result + ((leftValue == null) ? 0 : leftValue.hashCode()); + result = prime * result + (rightMaterialized ? 1231 : 1237); + 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; + LazyPair other = (LazyPair) obj; + if(leftMaterialized != other.leftMaterialized) return false; + if(leftValue == null) { + if(other.leftValue != null) return false; + } else if(!leftValue.equals(other.leftValue)) return false; + if(rightMaterialized != other.rightMaterialized) return false; + if(rightValue == null) { + if(other.rightValue != null) return false; + } else if(!rightValue.equals(other.rightValue)) return false; + return true; + } } |
