summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/Identity.java
diff options
context:
space:
mode:
authorbjculkin <bjculkin@WIT-136XG42.wvu-ad.wvu.edu>2017-04-07 10:51:31 -0400
committerbjculkin <bjculkin@WIT-136XG42.wvu-ad.wvu.edu>2017-04-07 10:51:31 -0400
commit63d88eb8db1f7a6d5924ec2a8b7f462373d5ac9a (patch)
tree4a7c67b23c8e1ecb1b2f992e5dbaf3ebb48dcf6b /BJC-Utils2/src/main/java/bjc/utils/data/Identity.java
parent848dc739becfa41193aff9a07c918aed91e5ef79 (diff)
Cleanup
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