summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/data/Identity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/bjc/data/Identity.java')
-rw-r--r--src/main/java/bjc/data/Identity.java40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/main/java/bjc/data/Identity.java b/src/main/java/bjc/data/Identity.java
index 8645c4c..c80c7e1 100644
--- a/src/main/java/bjc/data/Identity.java
+++ b/src/main/java/bjc/data/Identity.java
@@ -9,7 +9,7 @@ import java.util.function.UnaryOperator;
* @author ben
*
* @param <ContainedType>
- * The type contained in the holder.
+ * The type contained in the holder.
*/
public class Identity<ContainedType> implements IHolder<ContainedType> {
/* The held value. */
@@ -24,14 +24,15 @@ public class Identity<ContainedType> implements IHolder<ContainedType> {
* Create a holder holding the specified value.
*
* @param value
- * The value to hold.
+ * The value to hold.
*/
public Identity(final ContainedType value) {
heldValue = value;
}
@Override
- public <BoundType> IHolder<BoundType> bind(final Function<ContainedType, IHolder<BoundType>> binder) {
+ public <BoundType> IHolder<BoundType>
+ bind(final Function<ContainedType, IHolder<BoundType>> binder) {
return binder.apply(heldValue);
}
@@ -47,28 +48,35 @@ 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)) return false;
+ if (heldValue == null) {
+ if (other.heldValue != null)
+ return false;
+ } else if (!heldValue.equals(other.heldValue))
+ return false;
return true;
}
@Override
- public <NewType> Function<ContainedType, IHolder<NewType>> lift(final Function<ContainedType, NewType> func) {
- return (val) -> {
+ public <NewType> Function<ContainedType, IHolder<NewType>>
+ lift(final Function<ContainedType, NewType> func) {
+ return val -> {
return new Identity<>(func.apply(val));
};
}
@Override
- public <MappedType> IHolder<MappedType> map(final Function<ContainedType, MappedType> mapper) {
+ public <MappedType> IHolder<MappedType>
+ map(final Function<ContainedType, MappedType> mapper) {
return new Identity<>(mapper.apply(heldValue));
}
@@ -78,14 +86,16 @@ public class Identity<ContainedType> implements IHolder<ContainedType> {
}
@Override
- public IHolder<ContainedType> transform(final UnaryOperator<ContainedType> transformer) {
+ public IHolder<ContainedType>
+ transform(final UnaryOperator<ContainedType> transformer) {
heldValue = transformer.apply(heldValue);
return this;
}
@Override
- public <UnwrappedType> UnwrappedType unwrap(final Function<ContainedType, UnwrappedType> unwrapper) {
+ public <UnwrappedType> UnwrappedType
+ unwrap(final Function<ContainedType, UnwrappedType> unwrapper) {
return unwrapper.apply(heldValue);
}
@@ -93,7 +103,7 @@ public class Identity<ContainedType> implements IHolder<ContainedType> {
* Create a new identity container.
*
* @param val
- * The contained value.
+ * The contained value.
*
* @return A new identity container.
*/