From 27bf571d6413c3cc6a5d664b5bddd38d21d7b1cd Mon Sep 17 00:00:00 2001 From: EVE Date: Mon, 13 Mar 2017 16:42:21 -0400 Subject: Formatting --- .../java/bjc/utils/data/internals/BoundLazy.java | 38 +++++------- .../bjc/utils/data/internals/BoundLazyPair.java | 71 ++++++++-------------- .../bjc/utils/data/internals/BoundListHolder.java | 32 ++++------ .../utils/data/internals/HalfBoundLazyPair.java | 29 ++++----- .../bjc/utils/data/internals/WrappedOption.java | 3 +- 5 files changed, 64 insertions(+), 109 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/internals') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java index beb2465..57bf006 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java @@ -12,45 +12,42 @@ import bjc.utils.funcdata.IList; /** * Implements a lazy holder that has been bound */ -public class BoundLazy - implements IHolder { +public class BoundLazy implements IHolder { /* * The old value */ - private Supplier> oldSupplier; + private Supplier> oldSupplier; /* * The function to use to transform the old value into a new value */ - private Function> binder; + private Function> binder; /* * The bound value being held */ - private IHolder boundHolder; + private IHolder boundHolder; /* * Whether the bound value has been actualized or not */ - private boolean holderBound; + private boolean holderBound; /* * Transformations currently pending on the bound value */ - private IList> actions = new FunctionalList<>(); + private IList> actions = new FunctionalList<>(); /* * Create a new bound lazy value */ - public BoundLazy(Supplier> supp, - Function> binder) { + public BoundLazy(Supplier> supp, Function> binder) { oldSupplier = supp; this.binder = binder; } @Override - public IHolder bind( - Function> bindr) { + public IHolder bind(Function> bindr) { if (bindr == null) { throw new NullPointerException("Binder must not be null"); } @@ -89,8 +86,7 @@ public class BoundLazy public Function> lift( Function func) { if (func == null) { - throw new NullPointerException( - "Function to lift must not be null"); + throw new NullPointerException("Function to lift must not be null"); } return (val) -> { @@ -99,8 +95,7 @@ public class BoundLazy } @Override - public IHolder map( - Function mapper) { + public IHolder map(Function mapper) { if (mapper == null) { throw new NullPointerException("Mapper must not be null"); } @@ -118,10 +113,9 @@ public class BoundLazy oldHolder = oldSupplier.get().unwrap(binder); } - return pendingActions.reduceAux(oldHolder.getValue(), - (action, state) -> { - return action.apply(state); - }, (value) -> mapper.apply(value)); + return pendingActions.reduceAux(oldHolder.getValue(), (action, state) -> { + return action.apply(state); + }, (value) -> mapper.apply(value)); }; return new Lazy<>(typeSupplier); @@ -137,8 +131,7 @@ public class BoundLazy } @Override - public IHolder transform( - UnaryOperator transformer) { + public IHolder transform(UnaryOperator transformer) { if (transformer == null) { throw new NullPointerException("Transformer must not be null"); } @@ -149,8 +142,7 @@ public class BoundLazy } @Override - public UnwrappedType unwrap( - Function unwrapper) { + public UnwrappedType unwrap(Function unwrapper) { if (unwrapper == null) { throw new NullPointerException("Unwrapper must not be null"); } diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazyPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazyPair.java index 977fb37..d425d99 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazyPair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazyPair.java @@ -12,34 +12,32 @@ import bjc.utils.data.LazyPair; /** * Implements a lazy pair that has been bound */ -public class BoundLazyPair - implements IPair { +public class BoundLazyPair implements IPair { /* * The supplier of the left value */ - private Supplier leftSupplier; + private Supplier leftSupplier; /* * The supplier of the right value */ - private Supplier rightSupplier; + private Supplier rightSupplier; /* * The binder to transform values */ - private BiFunction> binder; + private BiFunction> binder; /* * The bound pair */ - private IPair boundPair; + private IPair boundPair; /* * Whether the pair has been bound yet */ - private boolean pairBound; + private boolean pairBound; - public BoundLazyPair(Supplier leftSupp, - Supplier rightSupp, + public BoundLazyPair(Supplier leftSupp, Supplier rightSupp, BiFunction> bindr) { leftSupplier = leftSupp; rightSupplier = rightSupp; @@ -53,14 +51,12 @@ public class BoundLazyPair throw new NullPointerException("Binder must not be null"); } - IHolder> newPair = new Identity<>( - boundPair); + IHolder> newPair = new Identity<>(boundPair); IHolder newPairMade = new Identity<>(pairBound); Supplier leftSupp = () -> { if (!newPairMade.getValue()) { - newPair.replace(binder.apply(leftSupplier.get(), - rightSupplier.get())); + newPair.replace(binder.apply(leftSupplier.get(), rightSupplier.get())); newPairMade.replace(true); } @@ -70,8 +66,7 @@ public class BoundLazyPair Supplier rightSupp = () -> { if (!newPairMade.getValue()) { - newPair.replace(binder.apply(leftSupplier.get(), - rightSupplier.get())); + newPair.replace(binder.apply(leftSupplier.get(), rightSupplier.get())); newPairMade.replace(true); } @@ -93,8 +88,7 @@ public class BoundLazyPair IPair newPair = boundPair; if (!pairBound) { - newPair = binder.apply(leftSupplier.get(), - rightSupplier.get()); + newPair = binder.apply(leftSupplier.get(), rightSupplier.get()); } return newPair.getLeft(); @@ -107,16 +101,14 @@ public class BoundLazyPair public IPair bindRight( Function> rightBinder) { if (rightBinder == null) { - throw new NullPointerException( - "Right binder must not be null"); + throw new NullPointerException("Right binder must not be null"); } Supplier rightSupp = () -> { IPair newPair = boundPair; if (!pairBound) { - newPair = binder.apply(leftSupplier.get(), - rightSupplier.get()); + newPair = binder.apply(leftSupplier.get(), rightSupplier.get()); } return newPair.getRight(); @@ -133,34 +125,28 @@ public class BoundLazyPair if (otherPair == null) { throw new NullPointerException("Other pair must not be null"); } else if (leftCombiner == null) { - throw new NullPointerException( - "Left combiner must not be null"); + throw new NullPointerException("Left combiner must not be null"); } else if (rightCombiner == null) { - throw new NullPointerException( - "Right combiner must not be null"); + throw new NullPointerException("Right combiner must not be null"); } return otherPair.bind((otherLeft, otherRight) -> { return bind((leftVal, rightVal) -> { - return new LazyPair<>( - leftCombiner.apply(leftVal, otherLeft), + return new LazyPair<>(leftCombiner.apply(leftVal, otherLeft), rightCombiner.apply(rightVal, otherRight)); }); }); } @Override - public IPair mapLeft( - Function mapper) { + public IPair mapLeft(Function mapper) { if (mapper == null) { throw new NullPointerException("Mapper must not be null"); } Supplier leftSupp = () -> { if (!pairBound) { - NewLeft leftVal = binder - .apply(leftSupplier.get(), rightSupplier.get()) - .getLeft(); + NewLeft leftVal = binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft(); return mapper.apply(leftVal); } @@ -170,9 +156,7 @@ public class BoundLazyPair Supplier rightSupp = () -> { if (!pairBound) { - return binder - .apply(leftSupplier.get(), rightSupplier.get()) - .getRight(); + return binder.apply(leftSupplier.get(), rightSupplier.get()).getRight(); } return boundPair.getRight(); @@ -182,17 +166,14 @@ public class BoundLazyPair } @Override - public IPair mapRight( - Function mapper) { + public IPair mapRight(Function mapper) { if (mapper == null) { throw new NullPointerException("Mapper must not be null"); } Supplier leftSupp = () -> { if (!pairBound) { - return binder - .apply(leftSupplier.get(), rightSupplier.get()) - .getLeft(); + return binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft(); } return boundPair.getLeft(); @@ -200,9 +181,7 @@ public class BoundLazyPair Supplier rightSupp = () -> { if (!pairBound) { - NewRight rightVal = binder - .apply(leftSupplier.get(), rightSupplier.get()) - .getRight(); + NewRight rightVal = binder.apply(leftSupplier.get(), rightSupplier.get()).getRight(); return mapper.apply(rightVal); } @@ -214,15 +193,13 @@ public class BoundLazyPair } @Override - public MergedType merge( - BiFunction merger) { + public MergedType merge(BiFunction merger) { if (merger == null) { throw new NullPointerException("Merger must not be null"); } if (!pairBound) { - boundPair = binder.apply(leftSupplier.get(), - rightSupplier.get()); + boundPair = binder.apply(leftSupplier.get(), rightSupplier.get()); pairBound = true; } diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundListHolder.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundListHolder.java index 7a3eaa8..f363b7e 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundListHolder.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundListHolder.java @@ -18,26 +18,22 @@ public class BoundListHolder implements IHolder { } @Override - public IHolder bind( - Function> binder) { + public IHolder bind(Function> binder) { if (binder == null) { throw new NullPointerException("Binder must not be null"); } - IList> boundHolders = heldHolders - .map((containedHolder) -> { - return containedHolder.bind(binder); - }); + IList> boundHolders = heldHolders.map((containedHolder) -> { + return containedHolder.bind(binder); + }); return new BoundListHolder<>(boundHolders); } @Override - public Function> lift( - Function func) { + public Function> lift(Function func) { if (func == null) { - throw new NullPointerException( - "Function to lift must not be null"); + throw new NullPointerException("Function to lift must not be null"); } return (val) -> { @@ -46,23 +42,20 @@ public class BoundListHolder implements IHolder { } @Override - public IHolder map( - Function mapper) { + public IHolder map(Function mapper) { if (mapper == null) { throw new NullPointerException("Mapper must not be null"); } - IList> mappedHolders = heldHolders - .map((containedHolder) -> { - return containedHolder.map(mapper); - }); + IList> mappedHolders = heldHolders.map((containedHolder) -> { + return containedHolder.map(mapper); + }); return new BoundListHolder<>(mappedHolders); } @Override - public IHolder transform( - UnaryOperator transformer) { + public IHolder transform(UnaryOperator transformer) { if (transformer == null) { throw new NullPointerException("Transformer must not be null"); } @@ -75,8 +68,7 @@ public class BoundListHolder implements IHolder { } @Override - public UnwrappedType unwrap( - Function unwrapper) { + public UnwrappedType unwrap(Function unwrapper) { if (unwrapper == null) { throw new NullPointerException("Unwrapper must not be null"); } diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java index 1e8d109..a8bdb6a 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java @@ -12,17 +12,15 @@ import bjc.utils.data.LazyPair; /* * A lazy pair, with only one side bound */ -public class HalfBoundLazyPair - implements IPair { - private Supplier oldSupplier; +public class HalfBoundLazyPair implements IPair { + private Supplier oldSupplier; - private Function> binder; + private Function> binder; - private IPair boundPair; - private boolean pairBound; + private IPair boundPair; + private boolean pairBound; - public HalfBoundLazyPair(Supplier oldSupp, - Function> bindr) { + public HalfBoundLazyPair(Supplier oldSupp, Function> bindr) { oldSupplier = oldSupp; binder = bindr; } @@ -30,8 +28,7 @@ public class HalfBoundLazyPair @Override public IPair bind( BiFunction> bindr) { - IHolder> newPair = new Identity<>( - boundPair); + IHolder> newPair = new Identity<>(boundPair); IHolder newPairMade = new Identity<>(pairBound); Supplier leftSupp = () -> { @@ -94,16 +91,14 @@ public class HalfBoundLazyPair BiFunction rightCombiner) { return otherPair.bind((otherLeft, otherRight) -> { return bind((leftVal, rightVal) -> { - return new LazyPair<>( - leftCombiner.apply(leftVal, otherLeft), + return new LazyPair<>(leftCombiner.apply(leftVal, otherLeft), rightCombiner.apply(rightVal, otherRight)); }); }); } @Override - public IPair mapLeft( - Function mapper) { + public IPair mapLeft(Function mapper) { Supplier leftSupp = () -> { if (pairBound) { return mapper.apply(boundPair.getLeft()); @@ -126,8 +121,7 @@ public class HalfBoundLazyPair } @Override - public IPair mapRight( - Function mapper) { + public IPair mapRight(Function mapper) { Supplier leftSupp = () -> { if (pairBound) { return boundPair.getLeft(); @@ -150,8 +144,7 @@ public class HalfBoundLazyPair } @Override - public MergedType merge( - BiFunction merger) { + public MergedType merge(BiFunction merger) { if (!pairBound) { boundPair = binder.apply(oldSupplier.get()); diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedOption.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedOption.java index 65c2463..2b03f62 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedOption.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/WrappedOption.java @@ -17,7 +17,8 @@ public class WrappedOption implements IHolder { held = toHold; } - @Override public IHolder bind(Function> binder) { + @Override + public IHolder bind(Function> binder) { IHolder> newHolder = held.map((containedHolder) -> { return containedHolder.bind((containedValue) -> { if (containedValue == null) { -- cgit v1.2.3