From 5cf7bcf156970fe72f79e40b8a6e320ea160ac83 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Fri, 21 Oct 2016 14:14:48 -0400 Subject: Documentation --- .../main/java/bjc/utils/data/BoundLazyPair.java | 55 ++++++++++++++-------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java') 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 622bd2e..2b3fb29 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java @@ -4,23 +4,38 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; +/** + * Implements a lazy pair that has been bound + */ class BoundLazyPair implements IPair { - private Supplier< - OldLeft> leftSupplier; - private Supplier< - OldRight> rightSupplier; - + /* + * The supplier of the left value + */ + private Supplier leftSupplier; + /* + * The supplier of the right value + */ + private Supplier rightSupplier; + + /* + * The binder to transform values + */ private BiFunction> binder; - private IPair boundPair; + /* + * The bound pair + */ + private IPair boundPair; + /* + * Whether the pair has been bound yet + */ private boolean pairBound; public BoundLazyPair(Supplier leftSupp, - Supplier rightSupp, BiFunction> bindr) { + Supplier rightSupp, + BiFunction> bindr) { leftSupplier = leftSupp; rightSupplier = rightSupp; binder = bindr; @@ -28,10 +43,13 @@ class BoundLazyPair @Override public IPair bind( - BiFunction> bindr) { - IHolder> newPair = new Identity<>(boundPair); + BiFunction> bindr) { + if (bindr == null) { + throw new NullPointerException("Binder must not be null"); + } + + IHolder> newPair = new Identity<>( + boundPair); IHolder newPairMade = new Identity<>(pairBound); Supplier leftSupp = () -> { @@ -94,13 +112,10 @@ 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<>( -- cgit v1.2.3