From 27bf571d6413c3cc6a5d664b5bddd38d21d7b1cd Mon Sep 17 00:00:00 2001 From: EVE Date: Mon, 13 Mar 2017 16:42:21 -0400 Subject: Formatting --- .../src/main/java/bjc/utils/data/Either.java | 57 +++++++++------------- 1 file changed, 23 insertions(+), 34 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/Either.java') 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 3ab4c00..7ec1720 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/Either.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/Either.java @@ -8,26 +8,24 @@ import java.util.function.Function; * * @author ben * @param - * The type that could be on the left + * The type that could be on the left * @param - * The type that could be on the right + * The type that could be on the right * */ -public class Either - implements IPair { +public class Either implements IPair { /** * Create a new either with the left value occupied * * @param - * The type of the left value + * The type of the left value * @param - * The type of the empty right value + * The type of the empty right value * @param left - * The value to put on the left + * 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); } @@ -35,25 +33,24 @@ public class Either * Create a new either with the right value occupied * * @param - * The type of the empty left value + * The type of the empty left value * @param - * The type of the right value + * The type of the right value * @param right - * The value to put on the right + * 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); } - private LeftType leftVal; + private LeftType leftVal; - private RightType rightVal; + private RightType rightVal; - private boolean isLeft; + private boolean isLeft; - private Either( LeftType left, RightType right) { + private Either(LeftType left, RightType right) { if (left == null) { rightVal = right; } else { @@ -91,8 +88,7 @@ public class Either public IPair bindRight( Function> rightBinder) { if (rightBinder == null) { - throw new NullPointerException( - "Right binder must not be null"); + throw new NullPointerException("Right binder must not be null"); } if (isLeft) { @@ -110,29 +106,24 @@ public class Either if (otherPair == null) { throw new NullPointerException("Other pair must not be null"); } else if (leftCombiner == null) { - throw new NullPointerException( - "Left combiner must not be null"); + throw new NullPointerException("Left combiner must not be null"); } else if (rightCombiner == null) { - throw new NullPointerException( - "Right combiner must not be null"); + throw new NullPointerException("Right combiner must not be null"); } if (isLeft) { return otherPair.bind((otherLeft, otherRight) -> { - return new Either<>(leftCombiner.apply(leftVal, otherLeft), - null); + return new Either<>(leftCombiner.apply(leftVal, otherLeft), null); }); } return otherPair.bind((otherLeft, otherRight) -> { - return new Either<>(null, - rightCombiner.apply(rightVal, otherRight)); + return new Either<>(null, rightCombiner.apply(rightVal, otherRight)); }); } @Override - public IPair mapLeft( - Function mapper) { + public IPair mapLeft(Function mapper) { if (mapper == null) { throw new NullPointerException("Mapper must not be null"); } @@ -145,8 +136,7 @@ public class Either } @Override - public IPair mapRight( - Function mapper) { + public IPair mapRight(Function mapper) { if (mapper == null) { throw new NullPointerException("Mapper must not be null"); } @@ -159,8 +149,7 @@ public class Either } @Override - public MergedType merge( - BiFunction merger) { + public MergedType merge(BiFunction merger) { if (merger == null) { throw new NullPointerException("Merger must not be null"); } -- cgit v1.2.3