summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java
diff options
context:
space:
mode:
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.java29
1 files changed, 22 insertions, 7 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 d19eed9..ea49b4c 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java
@@ -204,10 +204,12 @@ public class LazyPair<LeftType, RightType> implements IPair<LeftType, RightType>
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;
}
@@ -216,15 +218,28 @@ public class LazyPair<LeftType, RightType> implements IPair<LeftType, RightType>
if(this == obj) return true;
if(obj == null) return false;
if(getClass() != obj.getClass()) return false;
- LazyPair other = (LazyPair) obj;
+
+ 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(leftMaterialized) {
+ if(leftValue == null) {
+ if(other.leftValue != null) return false;
+ } else if(!leftValue.equals(other.leftValue)) return false;
+ } else {
+ 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;
+ if(rightMaterialized) {
+ if(rightValue == null) {
+ if(other.rightValue != null) return false;
+ } else if(!rightValue.equals(other.rightValue)) return false;
+ } else {
+ return false;
+ }
+
return true;
}
}