From 504ca816530efdff06bc202e0432ebd354aec304 Mon Sep 17 00:00:00 2001 From: EVE Date: Tue, 14 Mar 2017 12:07:14 -0400 Subject: Cleanup --- .../src/main/java/bjc/utils/data/LazyPair.java | 62 +++++++++------------- 1 file changed, 25 insertions(+), 37 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java') 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 29e37ac..59df1b1 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java @@ -1,36 +1,36 @@ package bjc.utils.data; +import bjc.utils.data.internals.BoundLazyPair; +import bjc.utils.data.internals.HalfBoundLazyPair; + import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; -import bjc.utils.data.internals.BoundLazyPair; -import bjc.utils.data.internals.HalfBoundLazyPair; - /** * A lazy implementation of a pair - * + * * @author ben * * @param * The type on the left side of the pair * @param * The type on the right side of the pair - * + * */ public class LazyPair implements IPair { - private LeftType leftValue; - private RightType rightValue; + private LeftType leftValue; + private RightType rightValue; - private Supplier leftSupplier; - private Supplier rightSupplier; + private Supplier leftSupplier; + private Supplier rightSupplier; - private boolean leftMaterialized; - private boolean rightMaterialized; + private boolean leftMaterialized; + private boolean rightMaterialized; /** * Create a new lazy pair, using the set values - * + * * @param leftVal * The value for the left side of the pair * @param rightVal @@ -46,7 +46,7 @@ public class LazyPair implements IPair /** * Create a new lazy pair from the given value sources - * + * * @param leftSupp * The source for a value on the left side of the pair * @param rightSupp @@ -71,9 +71,7 @@ public class LazyPair implements IPair public IPair bindLeft( Function> leftBinder) { Supplier leftSupp = () -> { - if (leftMaterialized) { - return leftValue; - } + if(leftMaterialized) return leftValue; return leftSupplier.get(); }; @@ -85,9 +83,7 @@ public class LazyPair implements IPair public IPair bindRight( Function> rightBinder) { Supplier rightSupp = () -> { - if (rightMaterialized) { - return rightValue; - } + if(rightMaterialized) return rightValue; return rightSupplier.get(); }; @@ -110,7 +106,7 @@ public class LazyPair implements IPair @Override public LeftType getLeft() { - if (!leftMaterialized) { + if(!leftMaterialized) { leftValue = leftSupplier.get(); leftMaterialized = true; @@ -121,7 +117,7 @@ public class LazyPair implements IPair @Override public RightType getRight() { - if (!rightMaterialized) { + if(!rightMaterialized) { rightValue = rightSupplier.get(); rightMaterialized = true; @@ -133,17 +129,13 @@ public class LazyPair implements IPair @Override public IPair mapLeft(Function mapper) { Supplier leftSupp = () -> { - if (leftMaterialized) { - return mapper.apply(leftValue); - } + if(leftMaterialized) return mapper.apply(leftValue); return mapper.apply(leftSupplier.get()); }; Supplier rightSupp = () -> { - if (rightMaterialized) { - return rightValue; - } + if(rightMaterialized) return rightValue; return rightSupplier.get(); }; @@ -154,17 +146,13 @@ public class LazyPair implements IPair @Override public IPair mapRight(Function mapper) { Supplier leftSupp = () -> { - if (leftMaterialized) { - return leftValue; - } + if(leftMaterialized) return leftValue; return leftSupplier.get(); }; Supplier rightSupp = () -> { - if (rightMaterialized) { - return mapper.apply(rightValue); - } + if(rightMaterialized) return mapper.apply(rightValue); return mapper.apply(rightSupplier.get()); }; @@ -174,13 +162,13 @@ public class LazyPair implements IPair @Override public MergedType merge(BiFunction merger) { - if (!leftMaterialized) { + if(!leftMaterialized) { leftValue = leftSupplier.get(); leftMaterialized = true; } - if (!rightMaterialized) { + if(!rightMaterialized) { rightValue = rightSupplier.get(); rightMaterialized = true; @@ -193,7 +181,7 @@ public class LazyPair implements IPair public String toString() { StringBuilder sb = new StringBuilder("pair[l="); - if (leftMaterialized) { + if(leftMaterialized) { sb.append(leftValue.toString()); } else { sb.append("(un-materialized)"); @@ -201,7 +189,7 @@ public class LazyPair implements IPair sb.append(", r="); - if (rightMaterialized) { + if(rightMaterialized) { sb.append(rightValue.toString()); } else { sb.append("(un-materialized)"); -- cgit v1.2.3