From 5cf7bcf156970fe72f79e40b8a6e320ea160ac83 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Fri, 21 Oct 2016 14:14:48 -0400 Subject: Documentation --- .../src/main/java/bjc/utils/data/BoundLazy.java | 32 +++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java index d6f3b1d..b2ae7ce 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java @@ -7,7 +7,7 @@ import java.util.function.UnaryOperator; import bjc.utils.funcdata.FunctionalList; import bjc.utils.funcdata.IList; -/* +/** * Implements a lazy holder that has been bound */ class BoundLazy @@ -35,8 +35,7 @@ class BoundLazy /* * Transformations currently pending on the bound value */ - private IList> actions = new FunctionalList<>(); + private IList> actions = new FunctionalList<>(); /* * Create a new bound lazy value @@ -50,11 +49,14 @@ class BoundLazy @Override public IHolder bind( Function> bindr) { + if (bindr == null) { + throw new NullPointerException("Binder must not be null"); + } + /* * Prepare a list of pending actions */ - IList> pendingActions = new FunctionalList<>(); + IList> pendingActions = new FunctionalList<>(); actions.forEach(pendingActions::add); /* @@ -84,6 +86,11 @@ class BoundLazy @Override public Function> lift( Function func) { + if (func == null) { + throw new NullPointerException( + "Function to lift must not be null"); + } + return (val) -> { return new Lazy<>(func.apply(val)); }; @@ -92,9 +99,12 @@ class BoundLazy @Override public IHolder map( Function mapper) { + if (mapper == null) { + throw new NullPointerException("Mapper must not be null"); + } + // Prepare a list of pending actions - IList> pendingActions = new FunctionalList<>(); + IList> pendingActions = new FunctionalList<>(); actions.forEach(pendingActions::add); // Prepare the new supplier @@ -127,6 +137,10 @@ class BoundLazy @Override public IHolder transform( UnaryOperator transformer) { + if (transformer == null) { + throw new NullPointerException("Transformer must not be null"); + } + actions.add(transformer); return this; @@ -135,6 +149,10 @@ class BoundLazy @Override public UnwrappedType unwrap( Function unwrapper) { + if (unwrapper == null) { + throw new NullPointerException("Unwrapper must not be null"); + } + if (!holderBound) { boundHolder = oldSupplier.get().unwrap(binder::apply); } -- cgit v1.2.3