summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/internals
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/internals')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java35
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazyPair.java99
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundListHolder.java34
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java75
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedLazy.java26
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedOption.java34
6 files changed, 153 insertions, 150 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java
index cc1c0c0..e5f1b95 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java
@@ -1,14 +1,14 @@
package bjc.utils.data.internals;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.function.UnaryOperator;
+
import bjc.utils.data.IHolder;
import bjc.utils.data.Lazy;
import bjc.utils.funcdata.FunctionalList;
import bjc.utils.funcdata.IList;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import java.util.function.UnaryOperator;
-
/*
* Implements a lazy holder that has been bound
*/
@@ -17,12 +17,12 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
/*
* The old value
*/
- private Supplier<IHolder<OldType>> oldSupplier;
+ private final Supplier<IHolder<OldType>> oldSupplier;
/*
* The function to use to transform the old value into a new value
*/
- private Function<OldType, IHolder<BoundContainedType>> binder;
+ private final Function<OldType, IHolder<BoundContainedType>> binder;
/*
* The bound value being held
@@ -37,30 +37,31 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
/*
* Transformations currently pending on the bound value
*/
- private IList<UnaryOperator<BoundContainedType>> actions = new FunctionalList<>();
+ private final IList<UnaryOperator<BoundContainedType>> actions = new FunctionalList<>();
/*
* Create a new bound lazy value
*/
- public BoundLazy(Supplier<IHolder<OldType>> supp, Function<OldType, IHolder<BoundContainedType>> binder) {
+ public BoundLazy(final Supplier<IHolder<OldType>> supp,
+ final Function<OldType, IHolder<BoundContainedType>> binder) {
oldSupplier = supp;
this.binder = binder;
}
@Override
- public <BoundType> IHolder<BoundType> bind(Function<BoundContainedType, IHolder<BoundType>> bindr) {
+ public <BoundType> IHolder<BoundType> bind(final Function<BoundContainedType, IHolder<BoundType>> bindr) {
if (bindr == null) throw new NullPointerException("Binder must not be null");
/*
* Prepare a list of pending actions
*/
- IList<UnaryOperator<BoundContainedType>> pendingActions = new FunctionalList<>();
+ final IList<UnaryOperator<BoundContainedType>> pendingActions = new FunctionalList<>();
actions.forEach(pendingActions::add);
/*
* Create the new supplier of a value
*/
- Supplier<IHolder<BoundContainedType>> typeSupplier = () -> {
+ final Supplier<IHolder<BoundContainedType>> typeSupplier = () -> {
IHolder<BoundContainedType> oldHolder = boundHolder;
/*
@@ -83,7 +84,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
@Override
public <NewType> Function<BoundContainedType, IHolder<NewType>> lift(
- Function<BoundContainedType, NewType> func) {
+ final Function<BoundContainedType, NewType> func) {
if (func == null) throw new NullPointerException("Function to lift must not be null");
return (val) -> {
@@ -92,15 +93,15 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
}
@Override
- public <MappedType> IHolder<MappedType> map(Function<BoundContainedType, MappedType> mapper) {
+ public <MappedType> IHolder<MappedType> map(final Function<BoundContainedType, MappedType> mapper) {
if (mapper == null) throw new NullPointerException("Mapper must not be null");
// Prepare a list of pending actions
- IList<UnaryOperator<BoundContainedType>> pendingActions = new FunctionalList<>();
+ final IList<UnaryOperator<BoundContainedType>> pendingActions = new FunctionalList<>();
actions.forEach(pendingActions::add);
// Prepare the new supplier
- Supplier<MappedType> typeSupplier = () -> {
+ final Supplier<MappedType> typeSupplier = () -> {
IHolder<BoundContainedType> oldHolder = boundHolder;
// Bound the value if it hasn't been bound
@@ -124,7 +125,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
}
@Override
- public IHolder<BoundContainedType> transform(UnaryOperator<BoundContainedType> transformer) {
+ public IHolder<BoundContainedType> transform(final UnaryOperator<BoundContainedType> transformer) {
if (transformer == null) throw new NullPointerException("Transformer must not be null");
actions.add(transformer);
@@ -133,7 +134,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
}
@Override
- public <UnwrappedType> UnwrappedType unwrap(Function<BoundContainedType, UnwrappedType> unwrapper) {
+ public <UnwrappedType> UnwrappedType unwrap(final Function<BoundContainedType, UnwrappedType> unwrapper) {
if (unwrapper == null) throw new NullPointerException("Unwrapper must not be null");
if (!holderBound) {
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazyPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazyPair.java
index de290a6..9333e15 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazyPair.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazyPair.java
@@ -1,14 +1,14 @@
package bjc.utils.data.internals;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
import bjc.utils.data.IHolder;
import bjc.utils.data.IPair;
import bjc.utils.data.Identity;
import bjc.utils.data.LazyPair;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.function.Supplier;
-
/*
* Implements a lazy pair that has been bound
*/
@@ -17,16 +17,16 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
/*
* The supplier of the left value
*/
- private Supplier<OldLeft> leftSupplier;
+ private final Supplier<OldLeft> leftSupplier;
/*
* The supplier of the right value
*/
- private Supplier<OldRight> rightSupplier;
+ private final Supplier<OldRight> rightSupplier;
/*
* The binder to transform values
*/
- private BiFunction<OldLeft, OldRight, IPair<NewLeft, NewRight>> binder;
+ private final BiFunction<OldLeft, OldRight, IPair<NewLeft, NewRight>> binder;
/*
* The bound pair
@@ -38,8 +38,8 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
*/
private boolean pairBound;
- public BoundLazyPair(Supplier<OldLeft> leftSupp, Supplier<OldRight> rightSupp,
- BiFunction<OldLeft, OldRight, IPair<NewLeft, NewRight>> bindr) {
+ public BoundLazyPair(final Supplier<OldLeft> leftSupp, final Supplier<OldRight> rightSupp,
+ final BiFunction<OldLeft, OldRight, IPair<NewLeft, NewRight>> bindr) {
leftSupplier = leftSupp;
rightSupplier = rightSupp;
binder = bindr;
@@ -47,14 +47,14 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public <BoundLeft, BoundRight> IPair<BoundLeft, BoundRight> bind(
- BiFunction<NewLeft, NewRight, IPair<BoundLeft, BoundRight>> bindr) {
- if(bindr == null) throw new NullPointerException("Binder must not be null");
+ final BiFunction<NewLeft, NewRight, IPair<BoundLeft, BoundRight>> bindr) {
+ if (bindr == null) throw new NullPointerException("Binder must not be null");
- IHolder<IPair<NewLeft, NewRight>> newPair = new Identity<>(boundPair);
- IHolder<Boolean> newPairMade = new Identity<>(pairBound);
+ final IHolder<IPair<NewLeft, NewRight>> newPair = new Identity<>(boundPair);
+ final IHolder<Boolean> newPairMade = new Identity<>(pairBound);
- Supplier<NewLeft> leftSupp = () -> {
- if(!newPairMade.getValue()) {
+ final Supplier<NewLeft> leftSupp = () -> {
+ if (!newPairMade.getValue()) {
newPair.replace(binder.apply(leftSupplier.get(), rightSupplier.get()));
newPairMade.replace(true);
@@ -63,8 +63,8 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
return newPair.unwrap((pair) -> pair.getLeft());
};
- Supplier<NewRight> rightSupp = () -> {
- if(!newPairMade.getValue()) {
+ final Supplier<NewRight> rightSupp = () -> {
+ if (!newPairMade.getValue()) {
newPair.replace(binder.apply(leftSupplier.get(), rightSupplier.get()));
newPairMade.replace(true);
@@ -78,13 +78,13 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public <BoundLeft> IPair<BoundLeft, NewRight> bindLeft(
- Function<NewLeft, IPair<BoundLeft, NewRight>> leftBinder) {
- if(leftBinder == null) throw new NullPointerException("Left binder must not be null");
+ final Function<NewLeft, IPair<BoundLeft, NewRight>> leftBinder) {
+ if (leftBinder == null) throw new NullPointerException("Left binder must not be null");
- Supplier<NewLeft> leftSupp = () -> {
+ final Supplier<NewLeft> leftSupp = () -> {
IPair<NewLeft, NewRight> newPair = boundPair;
- if(!pairBound) {
+ if (!pairBound) {
newPair = binder.apply(leftSupplier.get(), rightSupplier.get());
}
@@ -96,13 +96,13 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public <BoundRight> IPair<NewLeft, BoundRight> bindRight(
- Function<NewRight, IPair<NewLeft, BoundRight>> rightBinder) {
- if(rightBinder == null) throw new NullPointerException("Right binder must not be null");
+ final Function<NewRight, IPair<NewLeft, BoundRight>> rightBinder) {
+ if (rightBinder == null) throw new NullPointerException("Right binder must not be null");
- Supplier<NewRight> rightSupp = () -> {
+ final Supplier<NewRight> rightSupp = () -> {
IPair<NewLeft, NewRight> newPair = boundPair;
- if(!pairBound) {
+ if (!pairBound) {
newPair = binder.apply(leftSupplier.get(), rightSupplier.get());
}
@@ -114,14 +114,14 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public <OtherLeft, OtherRight, CombinedLeft, CombinedRight> IPair<CombinedLeft, CombinedRight> combine(
- IPair<OtherLeft, OtherRight> otherPair,
- BiFunction<NewLeft, OtherLeft, CombinedLeft> leftCombiner,
- BiFunction<NewRight, OtherRight, CombinedRight> rightCombiner) {
- if(otherPair == null)
+ final IPair<OtherLeft, OtherRight> otherPair,
+ final BiFunction<NewLeft, OtherLeft, CombinedLeft> leftCombiner,
+ final BiFunction<NewRight, OtherRight, CombinedRight> rightCombiner) {
+ if (otherPair == null)
throw new NullPointerException("Other pair must not be null");
- else if(leftCombiner == null)
+ else if (leftCombiner == null)
throw new NullPointerException("Left combiner must not be null");
- else if(rightCombiner == null) throw new NullPointerException("Right combiner must not be null");
+ else if (rightCombiner == null) throw new NullPointerException("Right combiner must not be null");
return otherPair.bind((otherLeft, otherRight) -> {
return bind((leftVal, rightVal) -> {
@@ -132,12 +132,12 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
}
@Override
- public <NewLeftType> IPair<NewLeftType, NewRight> mapLeft(Function<NewLeft, NewLeftType> mapper) {
- if(mapper == null) throw new NullPointerException("Mapper must not be null");
+ public <NewLeftType> IPair<NewLeftType, NewRight> mapLeft(final Function<NewLeft, NewLeftType> mapper) {
+ if (mapper == null) throw new NullPointerException("Mapper must not be null");
- Supplier<NewLeftType> leftSupp = () -> {
- if(!pairBound) {
- NewLeft leftVal = binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft();
+ final Supplier<NewLeftType> leftSupp = () -> {
+ if (!pairBound) {
+ final NewLeft leftVal = binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft();
return mapper.apply(leftVal);
}
@@ -145,8 +145,8 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
return mapper.apply(boundPair.getLeft());
};
- Supplier<NewRight> rightSupp = () -> {
- if(!pairBound) return binder.apply(leftSupplier.get(), rightSupplier.get()).getRight();
+ final Supplier<NewRight> rightSupp = () -> {
+ if (!pairBound) return binder.apply(leftSupplier.get(), rightSupplier.get()).getRight();
return boundPair.getRight();
};
@@ -155,18 +155,19 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
}
@Override
- public <NewRightType> IPair<NewLeft, NewRightType> mapRight(Function<NewRight, NewRightType> mapper) {
- if(mapper == null) throw new NullPointerException("Mapper must not be null");
+ public <NewRightType> IPair<NewLeft, NewRightType> mapRight(final Function<NewRight, NewRightType> mapper) {
+ if (mapper == null) throw new NullPointerException("Mapper must not be null");
- Supplier<NewLeft> leftSupp = () -> {
- if(!pairBound) return binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft();
+ final Supplier<NewLeft> leftSupp = () -> {
+ if (!pairBound) return binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft();
return boundPair.getLeft();
};
- Supplier<NewRightType> rightSupp = () -> {
- if(!pairBound) {
- NewRight rightVal = binder.apply(leftSupplier.get(), rightSupplier.get()).getRight();
+ final Supplier<NewRightType> rightSupp = () -> {
+ if (!pairBound) {
+ final NewRight rightVal = binder.apply(leftSupplier.get(), rightSupplier.get())
+ .getRight();
return mapper.apply(rightVal);
}
@@ -178,10 +179,10 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
}
@Override
- public <MergedType> MergedType merge(BiFunction<NewLeft, NewRight, MergedType> merger) {
- if(merger == null) throw new NullPointerException("Merger must not be null");
+ public <MergedType> MergedType merge(final BiFunction<NewLeft, NewRight, MergedType> merger) {
+ if (merger == null) throw new NullPointerException("Merger must not be null");
- if(!pairBound) {
+ if (!pairBound) {
boundPair = binder.apply(leftSupplier.get(), rightSupplier.get());
pairBound = true;
@@ -192,7 +193,7 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public String toString() {
- if(pairBound) return boundPair.toString();
+ if (pairBound) return boundPair.toString();
return "(un-materialized)";
}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundListHolder.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundListHolder.java
index c838ce7..65a6f3d 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundListHolder.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundListHolder.java
@@ -1,28 +1,28 @@
package bjc.utils.data.internals;
+import java.util.function.Function;
+import java.util.function.UnaryOperator;
+
import bjc.utils.data.IHolder;
import bjc.utils.data.ListHolder;
import bjc.utils.funcdata.IList;
-import java.util.function.Function;
-import java.util.function.UnaryOperator;
-
/*
* Holds a list, converted into a holder
*/
@SuppressWarnings("javadoc")
public class BoundListHolder<ContainedType> implements IHolder<ContainedType> {
- private IList<IHolder<ContainedType>> heldHolders;
+ private final IList<IHolder<ContainedType>> heldHolders;
- public BoundListHolder(IList<IHolder<ContainedType>> toHold) {
+ public BoundListHolder(final IList<IHolder<ContainedType>> toHold) {
heldHolders = toHold;
}
@Override
- public <BoundType> IHolder<BoundType> bind(Function<ContainedType, IHolder<BoundType>> binder) {
- if(binder == null) throw new NullPointerException("Binder must not be null");
+ public <BoundType> IHolder<BoundType> bind(final Function<ContainedType, IHolder<BoundType>> binder) {
+ if (binder == null) throw new NullPointerException("Binder must not be null");
- IList<IHolder<BoundType>> boundHolders = heldHolders.map((containedHolder) -> {
+ final IList<IHolder<BoundType>> boundHolders = heldHolders.map((containedHolder) -> {
return containedHolder.bind(binder);
});
@@ -30,8 +30,8 @@ public class BoundListHolder<ContainedType> implements IHolder<ContainedType> {
}
@Override
- public <NewType> Function<ContainedType, IHolder<NewType>> lift(Function<ContainedType, NewType> func) {
- if(func == null) throw new NullPointerException("Function to lift must not be null");
+ public <NewType> Function<ContainedType, IHolder<NewType>> lift(final Function<ContainedType, NewType> func) {
+ if (func == null) throw new NullPointerException("Function to lift must not be null");
return (val) -> {
return new ListHolder<>(func.apply(val));
@@ -39,10 +39,10 @@ public class BoundListHolder<ContainedType> implements IHolder<ContainedType> {
}
@Override
- public <MappedType> IHolder<MappedType> map(Function<ContainedType, MappedType> mapper) {
- if(mapper == null) throw new NullPointerException("Mapper must not be null");
+ public <MappedType> IHolder<MappedType> map(final Function<ContainedType, MappedType> mapper) {
+ if (mapper == null) throw new NullPointerException("Mapper must not be null");
- IList<IHolder<MappedType>> mappedHolders = heldHolders.map((containedHolder) -> {
+ final IList<IHolder<MappedType>> mappedHolders = heldHolders.map((containedHolder) -> {
return containedHolder.map(mapper);
});
@@ -50,8 +50,8 @@ public class BoundListHolder<ContainedType> implements IHolder<ContainedType> {
}
@Override
- public IHolder<ContainedType> transform(UnaryOperator<ContainedType> transformer) {
- if(transformer == null) throw new NullPointerException("Transformer must not be null");
+ public IHolder<ContainedType> transform(final UnaryOperator<ContainedType> transformer) {
+ if (transformer == null) throw new NullPointerException("Transformer must not be null");
heldHolders.forEach((containedHolder) -> {
containedHolder.transform(transformer);
@@ -61,8 +61,8 @@ public class BoundListHolder<ContainedType> implements IHolder<ContainedType> {
}
@Override
- public <UnwrappedType> UnwrappedType unwrap(Function<ContainedType, UnwrappedType> unwrapper) {
- if(unwrapper == null) throw new NullPointerException("Unwrapper must not be null");
+ public <UnwrappedType> UnwrappedType unwrap(final Function<ContainedType, UnwrappedType> unwrapper) {
+ if (unwrapper == null) throw new NullPointerException("Unwrapper must not be null");
return heldHolders.randItem().unwrap(unwrapper);
}
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java
index 35df1c3..a603a7f 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java
@@ -1,39 +1,40 @@
package bjc.utils.data.internals;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
import bjc.utils.data.IHolder;
import bjc.utils.data.IPair;
import bjc.utils.data.Identity;
import bjc.utils.data.LazyPair;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.function.Supplier;
-
/*
* A lazy pair, with only one side bound
*/
@SuppressWarnings("javadoc")
public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewLeft, NewRight> {
- private Supplier<OldType> oldSupplier;
+ private final Supplier<OldType> oldSupplier;
- private Function<OldType, IPair<NewLeft, NewRight>> binder;
+ private final Function<OldType, IPair<NewLeft, NewRight>> binder;
private IPair<NewLeft, NewRight> boundPair;
private boolean pairBound;
- public HalfBoundLazyPair(Supplier<OldType> oldSupp, Function<OldType, IPair<NewLeft, NewRight>> bindr) {
+ public HalfBoundLazyPair(final Supplier<OldType> oldSupp,
+ final Function<OldType, IPair<NewLeft, NewRight>> bindr) {
oldSupplier = oldSupp;
binder = bindr;
}
@Override
public <BoundLeft, BoundRight> IPair<BoundLeft, BoundRight> bind(
- BiFunction<NewLeft, NewRight, IPair<BoundLeft, BoundRight>> bindr) {
- IHolder<IPair<NewLeft, NewRight>> newPair = new Identity<>(boundPair);
- IHolder<Boolean> newPairMade = new Identity<>(pairBound);
+ final BiFunction<NewLeft, NewRight, IPair<BoundLeft, BoundRight>> bindr) {
+ final IHolder<IPair<NewLeft, NewRight>> newPair = new Identity<>(boundPair);
+ final IHolder<Boolean> newPairMade = new Identity<>(pairBound);
- Supplier<NewLeft> leftSupp = () -> {
- if(!newPairMade.getValue()) {
+ final Supplier<NewLeft> leftSupp = () -> {
+ if (!newPairMade.getValue()) {
newPair.replace(binder.apply(oldSupplier.get()));
newPairMade.replace(true);
}
@@ -41,8 +42,8 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
return newPair.unwrap((pair) -> pair.getLeft());
};
- Supplier<NewRight> rightSupp = () -> {
- if(!newPairMade.getValue()) {
+ final Supplier<NewRight> rightSupp = () -> {
+ if (!newPairMade.getValue()) {
newPair.replace(binder.apply(oldSupplier.get()));
newPairMade.replace(true);
}
@@ -55,11 +56,11 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
@Override
public <BoundLeft> IPair<BoundLeft, NewRight> bindLeft(
- Function<NewLeft, IPair<BoundLeft, NewRight>> leftBinder) {
- Supplier<NewLeft> leftSupp = () -> {
+ final Function<NewLeft, IPair<BoundLeft, NewRight>> leftBinder) {
+ final Supplier<NewLeft> leftSupp = () -> {
IPair<NewLeft, NewRight> newPair = boundPair;
- if(!pairBound) {
+ if (!pairBound) {
newPair = binder.apply(oldSupplier.get());
}
@@ -71,11 +72,11 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
@Override
public <BoundRight> IPair<NewLeft, BoundRight> bindRight(
- Function<NewRight, IPair<NewLeft, BoundRight>> rightBinder) {
- Supplier<NewRight> rightSupp = () -> {
+ final Function<NewRight, IPair<NewLeft, BoundRight>> rightBinder) {
+ final Supplier<NewRight> rightSupp = () -> {
IPair<NewLeft, NewRight> newPair = boundPair;
- if(!pairBound) {
+ if (!pairBound) {
newPair = binder.apply(oldSupplier.get());
}
@@ -87,9 +88,9 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
@Override
public <OtherLeft, OtherRight, CombinedLeft, CombinedRight> IPair<CombinedLeft, CombinedRight> combine(
- IPair<OtherLeft, OtherRight> otherPair,
- BiFunction<NewLeft, OtherLeft, CombinedLeft> leftCombiner,
- BiFunction<NewRight, OtherRight, CombinedRight> rightCombiner) {
+ final IPair<OtherLeft, OtherRight> otherPair,
+ final BiFunction<NewLeft, OtherLeft, CombinedLeft> leftCombiner,
+ final BiFunction<NewRight, OtherRight, CombinedRight> rightCombiner) {
return otherPair.bind((otherLeft, otherRight) -> {
return bind((leftVal, rightVal) -> {
return new LazyPair<>(leftCombiner.apply(leftVal, otherLeft),
@@ -99,17 +100,17 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
}
@Override
- public <NewLeftType> IPair<NewLeftType, NewRight> mapLeft(Function<NewLeft, NewLeftType> mapper) {
- Supplier<NewLeftType> leftSupp = () -> {
- if(pairBound) return mapper.apply(boundPair.getLeft());
+ public <NewLeftType> IPair<NewLeftType, NewRight> mapLeft(final Function<NewLeft, NewLeftType> mapper) {
+ final Supplier<NewLeftType> leftSupp = () -> {
+ if (pairBound) return mapper.apply(boundPair.getLeft());
- NewLeft leftVal = binder.apply(oldSupplier.get()).getLeft();
+ final NewLeft leftVal = binder.apply(oldSupplier.get()).getLeft();
return mapper.apply(leftVal);
};
- Supplier<NewRight> rightSupp = () -> {
- if(pairBound) return boundPair.getRight();
+ final Supplier<NewRight> rightSupp = () -> {
+ if (pairBound) return boundPair.getRight();
return binder.apply(oldSupplier.get()).getRight();
};
@@ -118,17 +119,17 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
}
@Override
- public <NewRightType> IPair<NewLeft, NewRightType> mapRight(Function<NewRight, NewRightType> mapper) {
- Supplier<NewLeft> leftSupp = () -> {
- if(pairBound) return boundPair.getLeft();
+ public <NewRightType> IPair<NewLeft, NewRightType> mapRight(final Function<NewRight, NewRightType> mapper) {
+ final Supplier<NewLeft> leftSupp = () -> {
+ if (pairBound) return boundPair.getLeft();
return binder.apply(oldSupplier.get()).getLeft();
};
- Supplier<NewRightType> rightSupp = () -> {
- if(pairBound) return mapper.apply(boundPair.getRight());
+ final Supplier<NewRightType> rightSupp = () -> {
+ if (pairBound) return mapper.apply(boundPair.getRight());
- NewRight rightVal = binder.apply(oldSupplier.get()).getRight();
+ final NewRight rightVal = binder.apply(oldSupplier.get()).getRight();
return mapper.apply(rightVal);
};
@@ -137,8 +138,8 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
}
@Override
- public <MergedType> MergedType merge(BiFunction<NewLeft, NewRight, MergedType> merger) {
- if(!pairBound) {
+ public <MergedType> MergedType merge(final BiFunction<NewLeft, NewRight, MergedType> merger) {
+ if (!pairBound) {
boundPair = binder.apply(oldSupplier.get());
pairBound = true;
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedLazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedLazy.java
index de161e5..d2e2b98 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedLazy.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedLazy.java
@@ -1,28 +1,28 @@
package bjc.utils.data.internals;
-import bjc.utils.data.IHolder;
-import bjc.utils.data.Lazy;
-
import java.util.function.Function;
import java.util.function.UnaryOperator;
+import bjc.utils.data.IHolder;
+import bjc.utils.data.Lazy;
+
@SuppressWarnings("javadoc")
public class WrappedLazy<ContainedType> implements IHolder<ContainedType> {
- private IHolder<IHolder<ContainedType>> held;
+ private final IHolder<IHolder<ContainedType>> held;
- public WrappedLazy(IHolder<ContainedType> wrappedHolder) {
+ public WrappedLazy(final IHolder<ContainedType> wrappedHolder) {
held = new Lazy<>(wrappedHolder);
}
// This has an extra parameter, because otherwise it erases to the same
// as the public one
- private WrappedLazy(IHolder<IHolder<ContainedType>> wrappedHolder, boolean dummy) {
+ private WrappedLazy(final IHolder<IHolder<ContainedType>> wrappedHolder, final boolean dummy) {
held = wrappedHolder;
}
@Override
- public <BoundType> IHolder<BoundType> bind(Function<ContainedType, IHolder<BoundType>> binder) {
- IHolder<IHolder<BoundType>> newHolder = held.map((containedHolder) -> {
+ public <BoundType> IHolder<BoundType> bind(final Function<ContainedType, IHolder<BoundType>> binder) {
+ final IHolder<IHolder<BoundType>> newHolder = held.map((containedHolder) -> {
return containedHolder.bind(binder);
});
@@ -30,15 +30,15 @@ public class WrappedLazy<ContainedType> implements IHolder<ContainedType> {
}
@Override
- public <NewType> Function<ContainedType, IHolder<NewType>> lift(Function<ContainedType, NewType> func) {
+ public <NewType> Function<ContainedType, IHolder<NewType>> lift(final Function<ContainedType, NewType> func) {
return (val) -> {
return new Lazy<>(func.apply(val));
};
}
@Override
- public <MappedType> IHolder<MappedType> map(Function<ContainedType, MappedType> mapper) {
- IHolder<IHolder<MappedType>> newHolder = held.map((containedHolder) -> {
+ public <MappedType> IHolder<MappedType> map(final Function<ContainedType, MappedType> mapper) {
+ final IHolder<IHolder<MappedType>> newHolder = held.map((containedHolder) -> {
return containedHolder.map(mapper);
});
@@ -46,7 +46,7 @@ public class WrappedLazy<ContainedType> implements IHolder<ContainedType> {
}
@Override
- public IHolder<ContainedType> transform(UnaryOperator<ContainedType> transformer) {
+ public IHolder<ContainedType> transform(final UnaryOperator<ContainedType> transformer) {
held.transform((containedHolder) -> {
return containedHolder.transform(transformer);
});
@@ -55,7 +55,7 @@ public class WrappedLazy<ContainedType> implements IHolder<ContainedType> {
}
@Override
- public <UnwrappedType> UnwrappedType unwrap(Function<ContainedType, UnwrappedType> unwrapper) {
+ public <UnwrappedType> UnwrappedType unwrap(final Function<ContainedType, UnwrappedType> unwrapper) {
return held.unwrap((containedHolder) -> {
return containedHolder.unwrap(unwrapper);
});
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedOption.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedOption.java
index e98332c..da53ab8 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedOption.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedOption.java
@@ -1,28 +1,28 @@
package bjc.utils.data.internals;
-import bjc.utils.data.IHolder;
-import bjc.utils.data.Option;
-
import java.util.function.Function;
import java.util.function.UnaryOperator;
+import bjc.utils.data.IHolder;
+import bjc.utils.data.Option;
+
@SuppressWarnings("javadoc")
public class WrappedOption<ContainedType> implements IHolder<ContainedType> {
- private IHolder<IHolder<ContainedType>> held;
+ private final IHolder<IHolder<ContainedType>> held;
- public WrappedOption(IHolder<ContainedType> seedValue) {
+ public WrappedOption(final IHolder<ContainedType> seedValue) {
held = new Option<>(seedValue);
}
- private WrappedOption(IHolder<IHolder<ContainedType>> toHold, boolean dummy) {
+ private WrappedOption(final IHolder<IHolder<ContainedType>> toHold, final boolean dummy) {
held = toHold;
}
@Override
- public <BoundType> IHolder<BoundType> bind(Function<ContainedType, IHolder<BoundType>> binder) {
- IHolder<IHolder<BoundType>> newHolder = held.map((containedHolder) -> {
+ public <BoundType> IHolder<BoundType> bind(final Function<ContainedType, IHolder<BoundType>> binder) {
+ final IHolder<IHolder<BoundType>> newHolder = held.map((containedHolder) -> {
return containedHolder.bind((containedValue) -> {
- if(containedValue == null) return new Option<>(null);
+ if (containedValue == null) return new Option<>(null);
return binder.apply(containedValue);
});
@@ -32,17 +32,17 @@ public class WrappedOption<ContainedType> implements IHolder<ContainedType> {
}
@Override
- public <NewType> Function<ContainedType, IHolder<NewType>> lift(Function<ContainedType, NewType> func) {
+ public <NewType> Function<ContainedType, IHolder<NewType>> lift(final Function<ContainedType, NewType> func) {
return (val) -> {
return new Option<>(func.apply(val));
};
}
@Override
- public <MappedType> IHolder<MappedType> map(Function<ContainedType, MappedType> mapper) {
- IHolder<IHolder<MappedType>> newHolder = held.map((containedHolder) -> {
+ public <MappedType> IHolder<MappedType> map(final Function<ContainedType, MappedType> mapper) {
+ final IHolder<IHolder<MappedType>> newHolder = held.map((containedHolder) -> {
return containedHolder.map((containedValue) -> {
- if(containedValue == null) return null;
+ if (containedValue == null) return null;
return mapper.apply(containedValue);
});
@@ -52,10 +52,10 @@ public class WrappedOption<ContainedType> implements IHolder<ContainedType> {
}
@Override
- public IHolder<ContainedType> transform(UnaryOperator<ContainedType> transformer) {
+ public IHolder<ContainedType> transform(final UnaryOperator<ContainedType> transformer) {
held.transform((containedHolder) -> {
return containedHolder.transform((containedValue) -> {
- if(containedValue == null) return null;
+ if (containedValue == null) return null;
return transformer.apply(containedValue);
});
@@ -65,10 +65,10 @@ public class WrappedOption<ContainedType> implements IHolder<ContainedType> {
}
@Override
- public <UnwrappedType> UnwrappedType unwrap(Function<ContainedType, UnwrappedType> unwrapper) {
+ public <UnwrappedType> UnwrappedType unwrap(final Function<ContainedType, UnwrappedType> unwrapper) {
return held.unwrap((containedHolder) -> {
return containedHolder.unwrap((containedValue) -> {
- if(containedValue == null) return null;
+ if (containedValue == null) return null;
return unwrapper.apply(containedValue);
});