From 27bf571d6413c3cc6a5d664b5bddd38d21d7b1cd Mon Sep 17 00:00:00 2001 From: EVE Date: Mon, 13 Mar 2017 16:42:21 -0400 Subject: Formatting --- BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java | 44 +++++++++-------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java index 6339795..3a037d7 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java @@ -9,28 +9,27 @@ import bjc.utils.funcdata.FunctionalList; import bjc.utils.funcdata.IList; /** - * A holder that holds a means to create a value, but doesn't actually - * compute the value until it's needed + * A holder that holds a means to create a value, but doesn't actually compute + * the value until it's needed * * @author ben * * @param */ public class Lazy implements IHolder { - private Supplier valueSupplier; + private Supplier valueSupplier; - private IList> actions = new FunctionalList<>(); + private IList> actions = new FunctionalList<>(); - private boolean valueMaterialized; + private boolean valueMaterialized; - private ContainedType heldValue; + private ContainedType heldValue; /** * Create a new lazy value from the specified seed value * * @param value - * The seed value to use + * The seed value to use */ public Lazy(ContainedType value) { heldValue = value; @@ -42,7 +41,7 @@ public class Lazy implements IHolder { * Create a new lazy value from the specified value source * * @param supp - * The source of a value to use + * The source of a value to use */ public Lazy(Supplier supp) { valueSupplier = new SingleSupplier<>(supp); @@ -50,18 +49,15 @@ public class Lazy implements IHolder { valueMaterialized = false; } - private Lazy(Supplier supp, - IList> pendingActions) { + private Lazy(Supplier supp, IList> pendingActions) { valueSupplier = supp; actions = pendingActions; } @Override - public IHolder bind( - Function> binder) { - IList> pendingActions = new FunctionalList<>(); + public IHolder bind(Function> binder) { + IList> pendingActions = new FunctionalList<>(); actions.forEach(pendingActions::add); @@ -79,18 +75,15 @@ public class Lazy implements IHolder { } @Override - public Function> lift( - Function func) { + public Function> lift(Function func) { return (val) -> { return new Lazy<>(func.apply(val)); }; } @Override - public IHolder map( - Function mapper) { - IList> pendingActions = new FunctionalList<>(); + public IHolder map(Function mapper) { + IList> pendingActions = new FunctionalList<>(); actions.forEach(pendingActions::add); @@ -101,8 +94,7 @@ public class Lazy implements IHolder { currVal = valueSupplier.get(); } - return pendingActions.reduceAux(currVal, - UnaryOperator::apply, + return pendingActions.reduceAux(currVal, UnaryOperator::apply, (value) -> mapper.apply(value)); }); } @@ -121,16 +113,14 @@ public class Lazy implements IHolder { } @Override - public IHolder transform( - UnaryOperator transformer) { + public IHolder transform(UnaryOperator transformer) { actions.add(transformer); return this; } @Override - public UnwrappedType unwrap( - Function unwrapper) { + public UnwrappedType unwrap(Function unwrapper) { if (!valueMaterialized) { heldValue = valueSupplier.get(); -- cgit v1.2.3