diff options
Diffstat (limited to 'src/main/java/bjc/data/Identity.java')
| -rw-r--r-- | src/main/java/bjc/data/Identity.java | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/main/java/bjc/data/Identity.java b/src/main/java/bjc/data/Identity.java index c80c7e1..fc4798e 100644 --- a/src/main/java/bjc/data/Identity.java +++ b/src/main/java/bjc/data/Identity.java @@ -11,7 +11,7 @@ import java.util.function.UnaryOperator; * @param <ContainedType> * The type contained in the holder. */ -public class Identity<ContainedType> implements IHolder<ContainedType> { +public class Identity<ContainedType> implements Holder<ContainedType> { /* The held value. */ private ContainedType heldValue; @@ -31,8 +31,8 @@ public class Identity<ContainedType> implements IHolder<ContainedType> { } @Override - public <BoundType> IHolder<BoundType> - bind(final Function<ContainedType, IHolder<BoundType>> binder) { + public <BoundType> Holder<BoundType> + bind(final Function<ContainedType, Holder<BoundType>> binder) { return binder.apply(heldValue); } @@ -48,26 +48,23 @@ public class Identity<ContainedType> implements IHolder<ContainedType> { @Override public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof Identity)) - return false; + if (this == obj) return true; + if (obj == null) return false; + if (!(obj instanceof Identity)) return false; final Identity<?> other = (Identity<?>) obj; if (heldValue == null) { - if (other.heldValue != null) - return false; - } else if (!heldValue.equals(other.heldValue)) + if (other.heldValue != null) return false; + } else if (!heldValue.equals(other.heldValue)) { return false; + } return true; } @Override - public <NewType> Function<ContainedType, IHolder<NewType>> + public <NewType> Function<ContainedType, Holder<NewType>> lift(final Function<ContainedType, NewType> func) { return val -> { return new Identity<>(func.apply(val)); @@ -75,7 +72,7 @@ public class Identity<ContainedType> implements IHolder<ContainedType> { } @Override - public <MappedType> IHolder<MappedType> + public <MappedType> Holder<MappedType> map(final Function<ContainedType, MappedType> mapper) { return new Identity<>(mapper.apply(heldValue)); } @@ -86,7 +83,7 @@ public class Identity<ContainedType> implements IHolder<ContainedType> { } @Override - public IHolder<ContainedType> + public Holder<ContainedType> transform(final UnaryOperator<ContainedType> transformer) { heldValue = transformer.apply(heldValue); @@ -102,8 +99,8 @@ public class Identity<ContainedType> implements IHolder<ContainedType> { /** * Create a new identity container. * - * @param val - * The contained value. + * @param <ContainedType> The type of the contained value. + * @param val The contained value. * * @return A new identity container. */ @@ -113,7 +110,9 @@ public class Identity<ContainedType> implements IHolder<ContainedType> { /** * Create a new empty identity container. - * + * + * @param <ContainedType> The type of the contained value. + * * @return A new empty identity container. */ public static <ContainedType> Identity<ContainedType> id() { |
