From d2af58b0f68ebfbba2be7e7679efec6c8c0af12f Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 9 Feb 2017 11:50:31 -0500 Subject: Update --- BJC-Utils2/src/main/java/bjc/utils/data/Pair.java | 46 +++++++++-------------- 1 file changed, 18 insertions(+), 28 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/Pair.java') 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 3480b2a..74040e8 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java @@ -13,10 +13,10 @@ import java.util.function.Function; * @param * The type of the right value */ -public class Pair - implements IPair { +public class Pair implements IPair { // The left value private LeftType leftValue; + // The right value private RightType rightValue; @@ -24,6 +24,7 @@ public class Pair * Create a new pair with both sides set to null */ public Pair() { + } /** @@ -41,8 +42,7 @@ public class Pair @Override public IPair bind( - BiFunction> binder) { + BiFunction> binder) { if (binder == null) { throw new NullPointerException("Binder must not be null."); } @@ -51,8 +51,7 @@ public class Pair } @Override - public IPair bindLeft( - Function> leftBinder) { + public IPair bindLeft(Function> leftBinder) { if (leftBinder == null) { throw new NullPointerException("Binder must not be null"); } @@ -61,8 +60,7 @@ public class Pair } @Override - public IPair bindRight( - Function> rightBinder) { + public IPair bindRight(Function> rightBinder) { if (rightBinder == null) { throw new NullPointerException("Binder must not be null"); } @@ -71,22 +69,17 @@ public class Pair } @Override - 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)); - }); + 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)); + }); } @Override - public IPair mapLeft( - Function mapper) { + public IPair mapLeft(Function mapper) { if (mapper == null) { throw new NullPointerException("Mapper must not be null"); } @@ -95,8 +88,7 @@ public class Pair } @Override - public IPair mapRight( - Function mapper) { + public IPair mapRight(Function mapper) { if (mapper == null) { throw new NullPointerException("Mapper must not be null"); } @@ -105,8 +97,7 @@ public class Pair } @Override - public MergedType merge( - BiFunction merger) { + public MergedType merge(BiFunction merger) { if (merger == null) { throw new NullPointerException("Merger must not be null"); } @@ -116,7 +107,6 @@ public class Pair @Override public String toString() { - return "pair[l=" + leftValue.toString() + ", r=" - + rightValue.toString() + "]"; + return "pair[l=" + leftValue.toString() + ", r=" + rightValue.toString() + "]"; } -} \ No newline at end of file +} -- cgit v1.2.3