summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2017-03-17 09:57:54 -0400
committerbjculkin <bjculkin@mix.wvu.edu>2017-03-17 09:57:54 -0400
commit6ea2b6868eb496f39bbbfb2d13662cb397d4d799 (patch)
tree343c6e0012e4c89bea75110171dafd08ad11d782 /BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java
parent7f59d0b9de4536705b3122cb5a85d9c9f85846a3 (diff)
More toString/hashCode/equals
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java
index d4d350a..7cf16fd 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java
@@ -131,4 +131,41 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> {
return unwrapper.apply(heldValue);
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+
+ result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+ result = prime * result + ((heldValue == null) ? 0 : heldValue.hashCode());
+ result = prime * result + (valueMaterialized ? 1231 : 1237);
+
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(this == obj) return true;
+ if(obj == null) return false;
+ if(getClass() != obj.getClass()) return false;
+
+ Lazy<?> other = (Lazy<?>) obj;
+
+ if(valueMaterialized != other.valueMaterialized) return false;
+
+ if(valueMaterialized) {
+ if(heldValue == null) {
+ if(other.heldValue != null) return false;
+ } else if(!heldValue.equals(other.heldValue)) return false;
+ } else {
+ return false;
+ }
+
+ if(actions == null) {
+ if(other.actions != null) return false;
+ } else if(actions.getSize() > 0 || other.actions.getSize() > 0) return false;
+
+ return true;
+ }
}