diff options
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/experimental/Identity.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/data/experimental/Identity.java | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/experimental/Identity.java b/BJC-Utils2/src/main/java/bjc/utils/data/experimental/Identity.java index 3cf0987..1780f2d 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/experimental/Identity.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/experimental/Identity.java @@ -42,29 +42,32 @@ public class Identity<ContainedType> implements IHolder<ContainedType> { return binder.apply(heldValue); } + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ @Override - public <MappedType> IHolder<MappedType> map( - Function<ContainedType, MappedType> mapper) { - return new Identity<>(mapper.apply(heldValue)); - } - - @Override - public IHolder<ContainedType> transform( - UnaryOperator<ContainedType> transformer) { - heldValue = transformer.apply(heldValue); + public boolean equals(Object obj) { + if (this == obj) { + return true; + } else if (obj == null) { + return false; + } else if (getClass() != obj.getClass()) { + return false; + } - return this; - } + Identity<?> other = (Identity<?>) obj; - @Override - public <UnwrappedType> UnwrappedType unwrap( - Function<ContainedType, UnwrappedType> unwrapper) { - return unwrapper.apply(heldValue); - } + if (heldValue == null) { + if (other.heldValue != null) { + return false; + } + } else if (!heldValue.equals(other.heldValue)) { + return false; + } - @Override - public String toString() { - return "holding[v=" + heldValue + "]"; + return true; } /* @@ -85,31 +88,28 @@ public class Identity<ContainedType> implements IHolder<ContainedType> { return result; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (obj == null) { - return false; - } else if (getClass() != obj.getClass()) { - return false; - } + public <MappedType> IHolder<MappedType> map( + Function<ContainedType, MappedType> mapper) { + return new Identity<>(mapper.apply(heldValue)); + } - Identity<?> other = (Identity<?>) obj; + @Override + public String toString() { + return "holding[v=" + heldValue + "]"; + } - if (heldValue == null) { - if (other.heldValue != null) { - return false; - } - } else if (!heldValue.equals(other.heldValue)) { - return false; - } + @Override + public IHolder<ContainedType> transform( + UnaryOperator<ContainedType> transformer) { + heldValue = transformer.apply(heldValue); - return true; + return this; + } + + @Override + public <UnwrappedType> UnwrappedType unwrap( + Function<ContainedType, UnwrappedType> unwrapper) { + return unwrapper.apply(heldValue); } }
\ No newline at end of file |
