From 6340caa7ec15be51c6d633a0519f3e0c76b25241 Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Mon, 9 Nov 2020 18:53:43 -0500 Subject: Formatting cleanup --- src/main/java/bjc/data/LazyPair.java | 66 ++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 36 deletions(-) (limited to 'src/main/java/bjc/data/LazyPair.java') diff --git a/src/main/java/bjc/data/LazyPair.java b/src/main/java/bjc/data/LazyPair.java index e668cd4..2481cd7 100644 --- a/src/main/java/bjc/data/LazyPair.java +++ b/src/main/java/bjc/data/LazyPair.java @@ -79,8 +79,7 @@ public class LazyPair implements IPair public IPair bindLeft(final Function> leftBinder) { final Supplier leftSupp = () -> { - if (leftMaterialized) - return leftValue; + if (leftMaterialized) return leftValue; return leftSupplier.get(); }; @@ -92,8 +91,7 @@ public class LazyPair implements IPair public IPair bindRight( final Function> rightBinder) { final Supplier rightSupp = () -> { - if (rightMaterialized) - return rightValue; + if (rightMaterialized) return rightValue; return rightSupplier.get(); }; @@ -108,12 +106,14 @@ public class LazyPair implements IPair final BiFunction leftCombiner, final BiFunction rightCombiner) { - return otherPair.bind((otherLeft, otherRight) -> bind((leftVal, rightVal) -> { - final CombinedLeft left = leftCombiner.apply(leftVal, otherLeft); - final CombinedRight right = rightCombiner.apply(rightVal, otherRight); - - return new LazyPair<>(left, right); - })); + return otherPair.bind((otherLeft, otherRight) -> { + return bind((leftVal, rightVal) -> { + final CombinedLeft left = leftCombiner.apply(leftVal, otherLeft); + final CombinedRight right = rightCombiner.apply(rightVal, otherRight); + + return new LazyPair<>(left, right); + }); + }); } @Override @@ -142,15 +142,13 @@ public class LazyPair implements IPair public IPair mapLeft(final Function mapper) { final Supplier leftSupp = () -> { - if (leftMaterialized) - return mapper.apply(leftValue); + if (leftMaterialized) return mapper.apply(leftValue); return mapper.apply(leftSupplier.get()); }; final Supplier rightSupp = () -> { - if (rightMaterialized) - return rightValue; + if (rightMaterialized) return rightValue; return rightSupplier.get(); }; @@ -162,15 +160,13 @@ public class LazyPair implements IPair public IPair mapRight(final Function mapper) { final Supplier leftSupp = () -> { - if (leftMaterialized) - return leftValue; + if (leftMaterialized) return leftValue; return leftSupplier.get(); }; final Supplier rightSupp = () -> { - if (rightMaterialized) - return mapper.apply(rightValue); + if (rightMaterialized) return mapper.apply(rightValue); return mapper.apply(rightSupplier.get()); }; @@ -231,37 +227,35 @@ public class LazyPair implements IPair @Override public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof LazyPair)) - return false; + if (this == obj) return true; + if (obj == null) return false; + if (!(obj instanceof LazyPair)) return false; final LazyPair other = (LazyPair) obj; - if (leftMaterialized != other.leftMaterialized) - return false; + if (leftMaterialized != other.leftMaterialized) return false; if (leftMaterialized) { if (leftValue == null) { - if (other.leftValue != null) - return false; - } else if (!leftValue.equals(other.leftValue)) + if (other.leftValue != null) return false; + } else if (!leftValue.equals(other.leftValue)) { return false; - } else + } + } else { return false; + } - if (rightMaterialized != other.rightMaterialized) - return false; + if (rightMaterialized != other.rightMaterialized) return false; + if (rightMaterialized) { if (rightValue == null) { - if (other.rightValue != null) - return false; - } else if (!rightValue.equals(other.rightValue)) + if (other.rightValue != null) return false; + } else if (!rightValue.equals(other.rightValue)) { return false; - } else + } + } else { return false; + } return true; } -- cgit v1.2.3