From 889fac2bdf993dc86f64a8893c0260fdcf848acb Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 10 Apr 2017 16:40:33 -0400 Subject: Cleanup --- .../utils/data/internals/HalfBoundLazyPair.java | 75 +++++++++++----------- 1 file changed, 38 insertions(+), 37 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java') 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 implements IPair { - private Supplier oldSupplier; + private final Supplier oldSupplier; - private Function> binder; + private final Function> binder; private IPair boundPair; private boolean pairBound; - public HalfBoundLazyPair(Supplier oldSupp, Function> bindr) { + public HalfBoundLazyPair(final Supplier oldSupp, + final Function> bindr) { oldSupplier = oldSupp; binder = bindr; } @Override public IPair bind( - BiFunction> bindr) { - IHolder> newPair = new Identity<>(boundPair); - IHolder newPairMade = new Identity<>(pairBound); + final BiFunction> bindr) { + final IHolder> newPair = new Identity<>(boundPair); + final IHolder newPairMade = new Identity<>(pairBound); - Supplier leftSupp = () -> { - if(!newPairMade.getValue()) { + final Supplier leftSupp = () -> { + if (!newPairMade.getValue()) { newPair.replace(binder.apply(oldSupplier.get())); newPairMade.replace(true); } @@ -41,8 +42,8 @@ public class HalfBoundLazyPair implements IPair pair.getLeft()); }; - Supplier rightSupp = () -> { - if(!newPairMade.getValue()) { + final Supplier rightSupp = () -> { + if (!newPairMade.getValue()) { newPair.replace(binder.apply(oldSupplier.get())); newPairMade.replace(true); } @@ -55,11 +56,11 @@ public class HalfBoundLazyPair implements IPair IPair bindLeft( - Function> leftBinder) { - Supplier leftSupp = () -> { + final Function> leftBinder) { + final Supplier leftSupp = () -> { IPair newPair = boundPair; - if(!pairBound) { + if (!pairBound) { newPair = binder.apply(oldSupplier.get()); } @@ -71,11 +72,11 @@ public class HalfBoundLazyPair implements IPair IPair bindRight( - Function> rightBinder) { - Supplier rightSupp = () -> { + final Function> rightBinder) { + final Supplier rightSupp = () -> { IPair newPair = boundPair; - if(!pairBound) { + if (!pairBound) { newPair = binder.apply(oldSupplier.get()); } @@ -87,9 +88,9 @@ public class HalfBoundLazyPair implements IPair IPair combine( - IPair otherPair, - BiFunction leftCombiner, - BiFunction rightCombiner) { + final IPair otherPair, + final BiFunction leftCombiner, + final BiFunction rightCombiner) { return otherPair.bind((otherLeft, otherRight) -> { return bind((leftVal, rightVal) -> { return new LazyPair<>(leftCombiner.apply(leftVal, otherLeft), @@ -99,17 +100,17 @@ public class HalfBoundLazyPair implements IPair IPair mapLeft(Function mapper) { - Supplier leftSupp = () -> { - if(pairBound) return mapper.apply(boundPair.getLeft()); + public IPair mapLeft(final Function mapper) { + final Supplier 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 rightSupp = () -> { - if(pairBound) return boundPair.getRight(); + final Supplier rightSupp = () -> { + if (pairBound) return boundPair.getRight(); return binder.apply(oldSupplier.get()).getRight(); }; @@ -118,17 +119,17 @@ public class HalfBoundLazyPair implements IPair IPair mapRight(Function mapper) { - Supplier leftSupp = () -> { - if(pairBound) return boundPair.getLeft(); + public IPair mapRight(final Function mapper) { + final Supplier leftSupp = () -> { + if (pairBound) return boundPair.getLeft(); return binder.apply(oldSupplier.get()).getLeft(); }; - Supplier rightSupp = () -> { - if(pairBound) return mapper.apply(boundPair.getRight()); + final Supplier 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 implements IPair MergedType merge(BiFunction merger) { - if(!pairBound) { + public MergedType merge(final BiFunction merger) { + if (!pairBound) { boundPair = binder.apply(oldSupplier.get()); pairBound = true; -- cgit v1.2.3