From f7a10e0e57d6f0ea83643c3d5763ff405af73337 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Wed, 28 Sep 2016 13:44:04 -0400 Subject: Formatting pass --- .../src/main/java/bjc/utils/data/BoundLazy.java | 9 ++++-- .../main/java/bjc/utils/data/BoundLazyPair.java | 31 +++++++++++-------- .../src/main/java/bjc/utils/data/Either.java | 25 ++++++++++------ .../java/bjc/utils/data/HalfBoundLazyPair.java | 18 ++++++----- .../src/main/java/bjc/utils/data/IHolder.java | 6 ++-- BJC-Utils2/src/main/java/bjc/utils/data/IPair.java | 35 ++++++++++++++-------- BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java | 9 ++++-- .../src/main/java/bjc/utils/data/LazyPair.java | 14 +++++---- BJC-Utils2/src/main/java/bjc/utils/data/Pair.java | 14 +++++---- 9 files changed, 103 insertions(+), 58 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java index b6cd715..d6f3b1d 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java @@ -35,7 +35,8 @@ class BoundLazy /* * Transformations currently pending on the bound value */ - private IList> actions = new FunctionalList<>(); + private IList> actions = new FunctionalList<>(); /* * Create a new bound lazy value @@ -52,7 +53,8 @@ class BoundLazy /* * Prepare a list of pending actions */ - IList> pendingActions = new FunctionalList<>(); + IList> pendingActions = new FunctionalList<>(); actions.forEach(pendingActions::add); /* @@ -91,7 +93,8 @@ class BoundLazy public IHolder map( Function mapper) { // Prepare a list of pending actions - IList> pendingActions = new FunctionalList<>(); + IList> pendingActions = new FunctionalList<>(); actions.forEach(pendingActions::add); // Prepare the new supplier diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java index c527d94..622bd2e 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java @@ -6,18 +6,21 @@ import java.util.function.Supplier; class BoundLazyPair implements IPair { - private Supplier leftSupplier; - private Supplier rightSupplier; + private Supplier< + OldLeft> leftSupplier; + private Supplier< + OldRight> rightSupplier; private BiFunction> binder; - private IPair boundPair; + private IPair boundPair; private boolean pairBound; public BoundLazyPair(Supplier leftSupp, - Supplier rightSupp, - BiFunction> bindr) { + Supplier rightSupp, BiFunction> bindr) { leftSupplier = leftSupp; rightSupplier = rightSupp; binder = bindr; @@ -25,9 +28,10 @@ class BoundLazyPair @Override public IPair bind( - BiFunction> bindr) { - IHolder> newPair = new Identity<>( - boundPair); + BiFunction> bindr) { + IHolder> newPair = new Identity<>(boundPair); IHolder newPairMade = new Identity<>(pairBound); Supplier leftSupp = () -> { @@ -90,10 +94,13 @@ class BoundLazyPair } @Override - public IPair combine( - IPair otherPair, - BiFunction leftCombiner, - BiFunction rightCombiner) { + public IPair combine( + IPair otherPair, + BiFunction leftCombiner, + BiFunction rightCombiner) { return otherPair.bind((otherLeft, otherRight) -> { return bind((leftVal, rightVal) -> { return new LazyPair<>( diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Either.java b/BJC-Utils2/src/main/java/bjc/utils/data/Either.java index 9418882..aa38959 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/Either.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/Either.java @@ -26,10 +26,12 @@ public class Either * The value to put on the left * @return An either with the left side occupied */ - public static Either fromLeft( - LeftType left) { + public static Either fromLeft( + LeftType left) { return new Either<>(left, null); } + /** * Create a new either with the right value occupied * @@ -41,8 +43,9 @@ public class Either * The value to put on the right * @return An either with the right side occupied */ - public static Either fromRight( - RightType right) { + public static Either fromRight( + RightType right) { return new Either<>(null, right); } @@ -64,7 +67,8 @@ public class Either @Override public IPair bind( - BiFunction> binder) { + BiFunction> binder) { return binder.apply(leftVal, rightVal); } @@ -89,10 +93,13 @@ public class Either } @Override - public IPair combine( - IPair otherPair, - BiFunction leftCombiner, - BiFunction rightCombiner) { + public IPair combine( + IPair otherPair, + BiFunction leftCombiner, + BiFunction rightCombiner) { if (isLeft) { return otherPair.bind((otherLeft, otherRight) -> { return new Either<>(leftCombiner.apply(leftVal, otherLeft), diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/HalfBoundLazyPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/HalfBoundLazyPair.java index d91ede2..72c0bdf 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/HalfBoundLazyPair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/HalfBoundLazyPair.java @@ -21,9 +21,10 @@ class HalfBoundLazyPair @Override public IPair bind( - BiFunction> bindr) { - IHolder> newPair = new Identity<>( - boundPair); + BiFunction> bindr) { + IHolder> newPair = new Identity<>(boundPair); IHolder newPairMade = new Identity<>(pairBound); Supplier leftSupp = () -> { @@ -80,10 +81,13 @@ class HalfBoundLazyPair } @Override - public IPair combine( - IPair otherPair, - BiFunction leftCombiner, - BiFunction rightCombiner) { + public IPair combine( + IPair otherPair, + BiFunction leftCombiner, + BiFunction rightCombiner) { return otherPair.bind((otherLeft, otherRight) -> { return bind((leftVal, rightVal) -> { return new LazyPair<>( diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/IHolder.java b/BJC-Utils2/src/main/java/bjc/utils/data/IHolder.java index b2e4369..a8c9f77 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/IHolder.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/IHolder.java @@ -43,8 +43,10 @@ public interface IHolder extends Functor { } @Override - default Function, Functor> fmap( - Function func) { + default Function, + Functor> fmap( + Function func) { return (argumentFunctor) -> { if (!(argumentFunctor instanceof IHolder)) { throw new IllegalArgumentException( diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/IPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/IPair.java index a2a635f..c82cc8e 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/IPair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/IPair.java @@ -30,7 +30,8 @@ public interface IPair * @return The bound pair */ public IPair bind( - BiFunction> binder); + BiFunction> binder); /** * Bind a function to the left value in this pair @@ -67,8 +68,10 @@ public interface IPair * The pair to combine with * @return The pairs, pairwise combined together */ - public default IPair, IPair> combine( - IPair otherPair) { + public default IPair, + IPair> combine( + IPair otherPair) { return combine(otherPair, (left, otherLeft) -> new Pair<>(left, otherLeft), (right, otherRight) -> new Pair<>(right, otherRight)); @@ -91,10 +94,13 @@ public interface IPair * @param rightCombiner * @return A pair with its values combined */ - public IPair combine( - IPair otherPair, - BiFunction leftCombiner, - BiFunction rightCombiner); + public IPair combine( + IPair otherPair, + BiFunction leftCombiner, + BiFunction rightCombiner); /** * Immediately perfom the specified action with the contents of this @@ -112,22 +118,26 @@ public interface IPair } @Override - default Function, Bifunctor> fmapLeft( - Function func) { + default Function, + Bifunctor> fmapLeft( + Function func) { return (argumentPair) -> { if (!(argumentPair instanceof IPair)) { throw new IllegalArgumentException( "This function can only be applied to instances of IPair"); } - IPair argPair = (IPair) argumentPair; + IPair argPair = (IPair) argumentPair; return argPair.mapLeft(func); }; } @Override - default Function, Bifunctor> + default Function< + Bifunctor, Bifunctor> fmapRight(Function func) { return (argumentPair) -> { @@ -136,7 +146,8 @@ public interface IPair "This function can only be applied to instances of IPair"); } - IPair argPair = (IPair) argumentPair; + IPair argPair = (IPair) argumentPair; return argPair.mapRight(func); }; diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java index f05204b..ffc4919 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java @@ -18,7 +18,8 @@ import bjc.utils.funcdata.IList; public class Lazy implements IHolder { private Supplier valueSupplier; - private IList> actions = new FunctionalList<>(); + private IList> actions = new FunctionalList<>(); private boolean valueMaterialized; @@ -58,7 +59,8 @@ public class Lazy implements IHolder { @Override public IHolder bind( Function> binder) { - IList> pendingActions = new FunctionalList<>(); + IList> pendingActions = new FunctionalList<>(); actions.forEach(pendingActions::add); @@ -86,7 +88,8 @@ public class Lazy implements IHolder { @Override public IHolder map( Function mapper) { - IList> pendingActions = new FunctionalList<>(); + IList> pendingActions = new FunctionalList<>(); actions.forEach(pendingActions::add); diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java index df4c3ac..53428d9 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java @@ -63,7 +63,8 @@ public class LazyPair @Override public IPair bind( - BiFunction> binder) { + BiFunction> binder) { return new BoundLazyPair<>(leftSupplier, rightSupplier, binder); } @@ -96,10 +97,13 @@ public class LazyPair } @Override - public IPair combine( - IPair otherPair, - BiFunction leftCombiner, - BiFunction rightCombiner) { + public IPair combine( + IPair otherPair, + BiFunction leftCombiner, + BiFunction rightCombiner) { return otherPair.bind((otherLeft, otherRight) -> { return bind((leftVal, rightVal) -> { return new LazyPair<>( diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java b/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java index 1000fc0..3480b2a 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java @@ -41,7 +41,8 @@ public class Pair @Override public IPair bind( - BiFunction> binder) { + BiFunction> binder) { if (binder == null) { throw new NullPointerException("Binder must not be null."); } @@ -70,10 +71,13 @@ public class Pair } @Override - public IPair combine( - IPair otherPair, - BiFunction leftCombiner, - BiFunction rightCombiner) { + public IPair combine( + IPair otherPair, + BiFunction leftCombiner, + BiFunction rightCombiner) { return otherPair.bind((otherLeft, otherRight) -> { return new Pair<>(leftCombiner.apply(leftValue, otherLeft), rightCombiner.apply(rightValue, otherRight)); -- cgit v1.2.3