summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/Identity.java
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/Identity.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/Identity.java41
1 files changed, 18 insertions, 23 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Identity.java b/BJC-Utils2/src/main/java/bjc/utils/data/Identity.java
index 72fe68c..77e13cf 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/Identity.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/Identity.java
@@ -41,42 +41,37 @@ public class Identity<ContainedType> implements IHolder<ContainedType> {
return binder.apply(heldValue);
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+
+ result = prime * result + ((heldValue == null) ? 0 : heldValue.hashCode());
+
+ return result;
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
- else if (obj == null)
+ if (obj == null)
+ return false;
+ if (!(obj instanceof Identity))
return false;
- else if (getClass() != obj.getClass()) return false;
Identity<?> other = (Identity<?>) obj;
if (heldValue == null) {
- if (other.heldValue != null) return false;
- } else if (!heldValue.equals(other.heldValue)) return false;
+ if (other.heldValue != null)
+ return false;
+ } else if (!heldValue.equals(other.heldValue))
+ return false;
return true;
}
@Override
- public int hashCode() {
- final int prime = 31;
-
- int result = 1;
-
- int fieldHash = heldValue == null ? 0 : heldValue.hashCode();
-
- result = prime * result + fieldHash;
-
- return result;
- }
-
- @Override
public <NewType> Function<ContainedType, IHolder<NewType>> lift(Function<ContainedType, NewType> func) {
return (val) -> {
return new Identity<>(func.apply(val));
@@ -90,7 +85,7 @@ public class Identity<ContainedType> implements IHolder<ContainedType> {
@Override
public String toString() {
- return "holding[v=" + heldValue + "]";
+ return String.format("Identity [heldValue=%s]", heldValue);
}
@Override