From f51f6da7319787348c38b875652b5c0e9f88c8aa Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Mon, 13 Apr 2020 18:43:13 -0400 Subject: Cleanup pass Pass to do some cleanups --- src/main/java/bjc/data/internals/BoundLazy.java | 66 ++++++----- .../java/bjc/data/internals/BoundLazyPair.java | 122 +++++++++++---------- .../java/bjc/data/internals/BoundListHolder.java | 50 +++++---- .../java/bjc/data/internals/HalfBoundLazyPair.java | 73 ++++++------ src/main/java/bjc/data/internals/WrappedLazy.java | 38 ++++--- .../java/bjc/data/internals/WrappedOption.java | 46 ++++---- 6 files changed, 223 insertions(+), 172 deletions(-) (limited to 'src/main/java/bjc/data/internals') diff --git a/src/main/java/bjc/data/internals/BoundLazy.java b/src/main/java/bjc/data/internals/BoundLazy.java index 728af8e..9c984eb 100644 --- a/src/main/java/bjc/data/internals/BoundLazy.java +++ b/src/main/java/bjc/data/internals/BoundLazy.java @@ -15,7 +15,8 @@ import bjc.funcdata.IList; * @author Ben Culkin */ @SuppressWarnings("javadoc") -public class BoundLazy implements IHolder { +public class BoundLazy + implements IHolder { /* The old value. */ private final Supplier> oldSupplier; @@ -29,16 +30,17 @@ public class BoundLazy implements IHolder> actions = new FunctionalList<>(); + private final IList> actions + = new FunctionalList<>(); /** * Create a new bound lazy value. * * @param supp - * The supplier of the old value. + * The supplier of the old value. * * @param binder - * The function to use to bind the old value to the new one. + * The function to use to bind the old value to the new one. */ public BoundLazy(final Supplier> supp, final Function> binder) { @@ -47,11 +49,14 @@ public class BoundLazy implements IHolder IHolder bind(final Function> bindr) { - if(bindr == null) throw new NullPointerException("Binder must not be null"); + public IHolder + bind(final Function> bindr) { + if (bindr == null) + throw new NullPointerException("Binder must not be null"); /* Prepare a list of pending actions. */ - final IList> pendingActions = new FunctionalList<>(); + final IList> pendingActions + = new FunctionalList<>(); actions.forEach(pendingActions::add); /* Create the new supplier of a value. */ @@ -59,35 +64,37 @@ public class BoundLazy implements IHolder oldHolder = boundHolder; /* Bind the value if it hasn't been bound before. */ - if(!holderBound) { + if (!holderBound) { oldHolder = oldSupplier.get().unwrap(binder); } /* Apply all the pending actions. */ - return pendingActions.reduceAux(oldHolder, (action, state) -> { - return state.transform(action); - }, (value) -> value); + return pendingActions.reduceAux(oldHolder, (action, state) -> state.transform(action), value -> value); }; return new BoundLazy<>(typeSupplier, bindr); } @Override - public Function> lift( - final Function func) { - if(func == null) throw new NullPointerException("Function to lift must not be null"); + public Function> + lift(final Function func) { + if (func == null) + throw new NullPointerException("Function to lift must not be null"); - return (val) -> { + return val -> { return new Lazy<>(func.apply(val)); }; } @Override - public IHolder map(final Function mapper) { - if(mapper == null) throw new NullPointerException("Mapper must not be null"); + public IHolder + map(final Function mapper) { + if (mapper == null) + throw new NullPointerException("Mapper must not be null"); /* Prepare a list of pending actions. */ - final IList> pendingActions = new FunctionalList<>(); + final IList> pendingActions + = new FunctionalList<>(); actions.forEach(pendingActions::add); /* Prepare the new supplier. */ @@ -95,14 +102,12 @@ public class BoundLazy implements IHolder oldHolder = boundHolder; /* Bound the value if it hasn't been bound. */ - if(!holderBound) { + if (!holderBound) { oldHolder = oldSupplier.get().unwrap(binder); } /* Apply pending actions. */ - return pendingActions.reduceAux(oldHolder.getValue(), (action, state) -> { - return action.apply(state); - }, (value) -> mapper.apply(value)); + return pendingActions.reduceAux(oldHolder.getValue(), (action, state) -> action.apply(state), value -> mapper.apply(value)); }; return new Lazy<>(typeSupplier); @@ -110,14 +115,17 @@ public class BoundLazy implements IHolder transform(final UnaryOperator transformer) { - if(transformer == null) throw new NullPointerException("Transformer must not be null"); + public IHolder + transform(final UnaryOperator transformer) { + if (transformer == null) + throw new NullPointerException("Transformer must not be null"); actions.add(transformer); @@ -125,10 +133,12 @@ public class BoundLazy implements IHolder UnwrappedType unwrap(final Function unwrapper) { - if(unwrapper == null) throw new NullPointerException("Unwrapper must not be null"); + public UnwrappedType + unwrap(final Function unwrapper) { + if (unwrapper == null) + throw new NullPointerException("Unwrapper must not be null"); - if(!holderBound) { + if (!holderBound) { boundHolder = oldSupplier.get().unwrap(binder::apply); } diff --git a/src/main/java/bjc/data/internals/BoundLazyPair.java b/src/main/java/bjc/data/internals/BoundLazyPair.java index 105b410..e081c04 100644 --- a/src/main/java/bjc/data/internals/BoundLazyPair.java +++ b/src/main/java/bjc/data/internals/BoundLazyPair.java @@ -15,7 +15,8 @@ import bjc.data.LazyPair; * @author Ben Culkin */ @SuppressWarnings("javadoc") -public class BoundLazyPair implements IPair { +public class BoundLazyPair + implements IPair { /* The supplier of the left value. */ private final Supplier leftSupplier; /* The supplier of the right value. */ @@ -34,16 +35,17 @@ public class BoundLazyPair implements IPai * Create a new bound lazy pair. * * @param leftSupp - * The supplier for the left value. + * The supplier for the left value. * * @param rightSupp - * The supplier for the right value. + * The supplier for the right value. * * @param bindr - * The function to use to bind the left and right into a new - * pair. + * The function to use to bind the left and right into a new + * pair. */ - public BoundLazyPair(final Supplier leftSupp, final Supplier rightSupp, + public BoundLazyPair(final Supplier leftSupp, + final Supplier rightSupp, final BiFunction> bindr) { leftSupplier = leftSupp; rightSupplier = rightSupp; @@ -53,54 +55,53 @@ public class BoundLazyPair implements IPai @Override public IPair bind( final BiFunction> bindr) { - if(bindr == null) throw new NullPointerException("Binder must not be null"); + if (bindr == null) + throw new NullPointerException("Binder must not be null"); final IHolder> newPair = new Identity<>(boundPair); final IHolder newPairMade = new Identity<>(pairBound); final Supplier leftSupp = () -> { - if(!newPairMade.getValue()) { + if (!newPairMade.getValue()) { /* - * If the pair hasn't been bound before, bind - * it. + * If the pair hasn't been bound before, bind it. */ newPair.replace(binder.apply(leftSupplier.get(), rightSupplier.get())); newPairMade.replace(true); } - return newPair.unwrap((pair) -> pair.getLeft()); + return newPair.unwrap(pair -> pair.getLeft()); }; final Supplier rightSupp = () -> { - if(!newPairMade.getValue()) { + if (!newPairMade.getValue()) { /* - * If the pair hasn't been bound before, bind - * it. + * If the pair hasn't been bound before, bind it. */ newPair.replace(binder.apply(leftSupplier.get(), rightSupplier.get())); newPairMade.replace(true); } - return newPair.unwrap((pair) -> pair.getRight()); + return newPair.unwrap(pair -> pair.getRight()); }; return new BoundLazyPair<>(leftSupp, rightSupp, bindr); } @Override - public IPair bindLeft( - final Function> leftBinder) { - if(leftBinder == null) throw new NullPointerException("Left binder must not be null"); + public IPair + bindLeft(final Function> leftBinder) { + if (leftBinder == null) + throw new NullPointerException("Left binder must not be null"); final Supplier leftSupp = () -> { IPair newPair = boundPair; - if(!pairBound) { + if (!pairBound) { /* - * If the pair hasn't been bound before, bind - * it. + * If the pair hasn't been bound before, bind it. */ newPair = binder.apply(leftSupplier.get(), rightSupplier.get()); } @@ -112,17 +113,17 @@ public class BoundLazyPair implements IPai } @Override - public IPair bindRight( - final Function> rightBinder) { - if(rightBinder == null) throw new NullPointerException("Right binder must not be null"); + public IPair + bindRight(final Function> rightBinder) { + if (rightBinder == null) + throw new NullPointerException("Right binder must not be null"); final Supplier rightSupp = () -> { IPair newPair = boundPair; - if(!pairBound) { + if (!pairBound) { /* - * If the pair hasn't been bound before, bind - * it. + * If the pair hasn't been bound before, bind it. */ newPair = binder.apply(leftSupplier.get(), rightSupplier.get()); } @@ -134,35 +135,37 @@ public class BoundLazyPair implements IPai } @Override - public IPair combine( - final IPair otherPair, - final BiFunction leftCombiner, - final BiFunction rightCombiner) { - if(otherPair == null) { + public + IPair + combine(final IPair otherPair, + final BiFunction leftCombiner, + final BiFunction rightCombiner) { + if (otherPair == null) { throw new NullPointerException("Other pair must not be null"); - } else if(leftCombiner == null) { + } else if (leftCombiner == null) { throw new NullPointerException("Left combiner must not be null"); - } else if(rightCombiner == null) { + } else if (rightCombiner == null) { throw new NullPointerException("Right combiner must not be null"); } - return otherPair.bind((otherLeft, otherRight) -> { - return bind((leftVal, rightVal) -> { - CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft); - CombinedRight cRight = rightCombiner.apply(rightVal, otherRight); + return otherPair.bind((otherLeft, otherRight) -> bind((leftVal, rightVal) -> { + CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft); + CombinedRight cRight = rightCombiner.apply(rightVal, otherRight); - return new LazyPair<>(cLeft, cRight); - }); - }); + return new LazyPair<>(cLeft, cRight); + })); } @Override - public IPair mapLeft(final Function mapper) { - if(mapper == null) throw new NullPointerException("Mapper must not be null"); + public IPair + mapLeft(final Function mapper) { + if (mapper == null) + throw new NullPointerException("Mapper must not be null"); final Supplier leftSupp = () -> { - if(!pairBound) { - final NewLeft leftVal = binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft(); + if (!pairBound) { + final NewLeft leftVal + = binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft(); return mapper.apply(leftVal); } @@ -171,7 +174,8 @@ public class BoundLazyPair implements IPai }; final Supplier rightSupp = () -> { - if(!pairBound) return binder.apply(leftSupplier.get(), rightSupplier.get()).getRight(); + if (!pairBound) + return binder.apply(leftSupplier.get(), rightSupplier.get()).getRight(); return boundPair.getRight(); }; @@ -180,19 +184,22 @@ public class BoundLazyPair implements IPai } @Override - public IPair mapRight(final Function mapper) { - if(mapper == null) throw new NullPointerException("Mapper must not be null"); + public IPair + mapRight(final Function mapper) { + if (mapper == null) + throw new NullPointerException("Mapper must not be null"); final Supplier leftSupp = () -> { - if(!pairBound) return binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft(); + if (!pairBound) + return binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft(); return boundPair.getLeft(); }; final Supplier rightSupp = () -> { - if(!pairBound) { - final NewRight rightVal = binder.apply(leftSupplier.get(), rightSupplier.get()) - .getRight(); + if (!pairBound) { + final NewRight rightVal = binder + .apply(leftSupplier.get(), rightSupplier.get()).getRight(); return mapper.apply(rightVal); } @@ -204,10 +211,12 @@ public class BoundLazyPair implements IPai } @Override - public MergedType merge(final BiFunction merger) { - if(merger == null) throw new NullPointerException("Merger must not be null"); + public MergedType + merge(final BiFunction merger) { + if (merger == null) + throw new NullPointerException("Merger must not be null"); - if(!pairBound) { + if (!pairBound) { /* * If the pair isn't bound yet, bind it. */ @@ -221,7 +230,8 @@ public class BoundLazyPair implements IPai @Override public String toString() { - if(pairBound) return boundPair.toString(); + if (pairBound) + return boundPair.toString(); return "(un-materialized)"; } diff --git a/src/main/java/bjc/data/internals/BoundListHolder.java b/src/main/java/bjc/data/internals/BoundListHolder.java index 8f8cab4..1193c8d 100644 --- a/src/main/java/bjc/data/internals/BoundListHolder.java +++ b/src/main/java/bjc/data/internals/BoundListHolder.java @@ -21,48 +21,58 @@ public class BoundListHolder implements IHolder { * Create a new list of holders. * * @param toHold - * The list of holders to, well, hold. + * The list of holders to, well, hold. */ public BoundListHolder(final IList> toHold) { heldHolders = toHold; } @Override - public IHolder bind(final Function> binder) { - if(binder == null) throw new NullPointerException("Binder must not be null"); + public IHolder + bind(final Function> binder) { + if (binder == null) + throw new NullPointerException("Binder must not be null"); - final IList> boundHolders = heldHolders.map((containedHolder) -> { - return containedHolder.bind(binder); - }); + final IList> boundHolders + = heldHolders.map(containedHolder -> { + return containedHolder.bind(binder); + }); return new BoundListHolder<>(boundHolders); } @Override - public Function> lift(final Function func) { - if(func == null) throw new NullPointerException("Function to lift must not be null"); + public Function> + lift(final Function func) { + if (func == null) + throw new NullPointerException("Function to lift must not be null"); - return (val) -> { + return val -> { return new ListHolder<>(func.apply(val)); }; } @Override - public IHolder map(final Function mapper) { - if(mapper == null) throw new NullPointerException("Mapper must not be null"); + public IHolder + map(final Function mapper) { + if (mapper == null) + throw new NullPointerException("Mapper must not be null"); - final IList> mappedHolders = heldHolders.map((containedHolder) -> { - return containedHolder.map(mapper); - }); + final IList> mappedHolders + = heldHolders.map(containedHolder -> { + return containedHolder.map(mapper); + }); return new BoundListHolder<>(mappedHolders); } @Override - public IHolder transform(final UnaryOperator transformer) { - if(transformer == null) throw new NullPointerException("Transformer must not be null"); + public IHolder + transform(final UnaryOperator transformer) { + if (transformer == null) + throw new NullPointerException("Transformer must not be null"); - heldHolders.forEach((containedHolder) -> { + heldHolders.forEach(containedHolder -> { containedHolder.transform(transformer); }); @@ -70,8 +80,10 @@ public class BoundListHolder implements IHolder { } @Override - public UnwrappedType unwrap(final Function unwrapper) { - if(unwrapper == null) throw new NullPointerException("Unwrapper must not be null"); + public UnwrappedType + unwrap(final Function unwrapper) { + if (unwrapper == null) + throw new NullPointerException("Unwrapper must not be null"); /* * @NOTE Is there another way we could want to do this? diff --git a/src/main/java/bjc/data/internals/HalfBoundLazyPair.java b/src/main/java/bjc/data/internals/HalfBoundLazyPair.java index 4f28012..6bcb6ae 100644 --- a/src/main/java/bjc/data/internals/HalfBoundLazyPair.java +++ b/src/main/java/bjc/data/internals/HalfBoundLazyPair.java @@ -23,7 +23,8 @@ import bjc.data.LazyPair; * @author Ben Culkin */ @SuppressWarnings("javadoc") -public class HalfBoundLazyPair implements IPair { +public class HalfBoundLazyPair + implements IPair { /* The supplier of the old value. */ private final Supplier oldSupplier; @@ -39,10 +40,10 @@ public class HalfBoundLazyPair implements IPair oldSupp, final Function> bindr) { @@ -57,35 +58,35 @@ public class HalfBoundLazyPair implements IPair newPairMade = new Identity<>(pairBound); final Supplier leftSupp = () -> { - if(!newPairMade.getValue()) { + if (!newPairMade.getValue()) { /* Bind the pair if it hasn't been bound yet. */ newPair.replace(binder.apply(oldSupplier.get())); newPairMade.replace(true); } - return newPair.unwrap((pair) -> pair.getLeft()); + return newPair.unwrap(pair -> pair.getLeft()); }; final Supplier rightSupp = () -> { - if(!newPairMade.getValue()) { + if (!newPairMade.getValue()) { /* Bind the pair if it hasn't been bound yet. */ newPair.replace(binder.apply(oldSupplier.get())); newPairMade.replace(true); } - return newPair.unwrap((pair) -> pair.getRight()); + return newPair.unwrap(pair -> pair.getRight()); }; return new BoundLazyPair<>(leftSupp, rightSupp, bindr); } @Override - public IPair bindLeft( - final Function> leftBinder) { + public IPair + bindLeft(final Function> leftBinder) { final Supplier leftSupp = () -> { IPair newPair = boundPair; - if(!pairBound) { + if (!pairBound) { newPair = binder.apply(oldSupplier.get()); } @@ -96,12 +97,12 @@ public class HalfBoundLazyPair implements IPair IPair bindRight( - final Function> rightBinder) { + public IPair + bindRight(final Function> rightBinder) { final Supplier rightSupp = () -> { IPair newPair = boundPair; - if(!pairBound) { + if (!pairBound) { newPair = binder.apply(oldSupplier.get()); } @@ -112,24 +113,25 @@ public class HalfBoundLazyPair implements IPair IPair combine( - final IPair otherPair, - final BiFunction leftCombiner, - final BiFunction rightCombiner) { - return otherPair.bind((otherLeft, otherRight) -> { - return bind((leftVal, rightVal) -> { - CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft); - CombinedRight cRight = rightCombiner.apply(rightVal, otherRight); - - return new LazyPair<>(cLeft, cRight); - }); - }); + public + IPair + combine(final IPair otherPair, + final BiFunction leftCombiner, + final BiFunction rightCombiner) { + return otherPair.bind((otherLeft, otherRight) -> bind((leftVal, rightVal) -> { + CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft); + CombinedRight cRight = rightCombiner.apply(rightVal, otherRight); + + return new LazyPair<>(cLeft, cRight); + })); } @Override - public IPair mapLeft(final Function mapper) { + public IPair + mapLeft(final Function mapper) { final Supplier leftSupp = () -> { - if(pairBound) return mapper.apply(boundPair.getLeft()); + if (pairBound) + return mapper.apply(boundPair.getLeft()); final NewLeft leftVal = binder.apply(oldSupplier.get()).getLeft(); @@ -137,7 +139,8 @@ public class HalfBoundLazyPair implements IPair rightSupp = () -> { - if(pairBound) return boundPair.getRight(); + if (pairBound) + return boundPair.getRight(); return binder.apply(oldSupplier.get()).getRight(); }; @@ -146,15 +149,18 @@ public class HalfBoundLazyPair implements IPair IPair mapRight(final Function mapper) { + public IPair + mapRight(final Function mapper) { final Supplier leftSupp = () -> { - if(pairBound) return boundPair.getLeft(); + if (pairBound) + return boundPair.getLeft(); return binder.apply(oldSupplier.get()).getLeft(); }; final Supplier rightSupp = () -> { - if(pairBound) return mapper.apply(boundPair.getRight()); + if (pairBound) + return mapper.apply(boundPair.getRight()); final NewRight rightVal = binder.apply(oldSupplier.get()).getRight(); @@ -165,8 +171,9 @@ public class HalfBoundLazyPair implements IPair MergedType merge(final BiFunction merger) { - if(!pairBound) { + public MergedType + merge(final BiFunction merger) { + if (!pairBound) { boundPair = binder.apply(oldSupplier.get()); pairBound = true; diff --git a/src/main/java/bjc/data/internals/WrappedLazy.java b/src/main/java/bjc/data/internals/WrappedLazy.java index 17d2309..cda86fd 100644 --- a/src/main/java/bjc/data/internals/WrappedLazy.java +++ b/src/main/java/bjc/data/internals/WrappedLazy.java @@ -11,7 +11,7 @@ import bjc.data.Lazy; * * @author Ben Culkin * @param - * The type of the wrapped value. + * The type of the wrapped value. */ public class WrappedLazy implements IHolder { /* Held value. */ @@ -21,19 +21,18 @@ public class WrappedLazy implements IHolder { * Create a new wrapped lazy value. * * @param wrappedHolder - * The holder to make lazy. + * The holder to make lazy. */ public WrappedLazy(final IHolder wrappedHolder) { held = new Lazy<>(wrappedHolder); } /* - * This has an extra parameter, because otherwise it erases to the same - * as the public one. + * This has an extra parameter, because otherwise it erases to the same as the + * public one. * - * This is a case where reified generics would be useful, because then - * the compiler could know which one we meant without the dummy - * parameter. + * This is a case where reified generics would be useful, because then the + * compiler could know which one we meant without the dummy parameter. */ private WrappedLazy(final IHolder> wrappedHolder, @SuppressWarnings("unused") final boolean dummy) { @@ -41,8 +40,9 @@ public class WrappedLazy implements IHolder { } @Override - public IHolder bind(final Function> binder) { - final IHolder> newHolder = held.map((containedHolder) -> { + public IHolder + bind(final Function> binder) { + final IHolder> newHolder = held.map(containedHolder -> { return containedHolder.bind(binder); }); @@ -50,15 +50,17 @@ public class WrappedLazy implements IHolder { } @Override - public Function> lift(final Function func) { - return (val) -> { + public Function> + lift(final Function func) { + return val -> { return new Lazy<>(func.apply(val)); }; } @Override - public IHolder map(final Function mapper) { - final IHolder> newHolder = held.map((containedHolder) -> { + public IHolder + map(final Function mapper) { + final IHolder> newHolder = held.map(containedHolder -> { return containedHolder.map(mapper); }); @@ -66,8 +68,9 @@ public class WrappedLazy implements IHolder { } @Override - public IHolder transform(final UnaryOperator transformer) { - held.transform((containedHolder) -> { + public IHolder + transform(final UnaryOperator transformer) { + held.transform(containedHolder -> { return containedHolder.transform(transformer); }); @@ -75,8 +78,9 @@ public class WrappedLazy implements IHolder { } @Override - public UnwrappedType unwrap(final Function unwrapper) { - return held.unwrap((containedHolder) -> { + public UnwrappedType + unwrap(final Function unwrapper) { + return held.unwrap(containedHolder -> { return containedHolder.unwrap(unwrapper); }); } diff --git a/src/main/java/bjc/data/internals/WrappedOption.java b/src/main/java/bjc/data/internals/WrappedOption.java index eb4d120..6becc16 100644 --- a/src/main/java/bjc/data/internals/WrappedOption.java +++ b/src/main/java/bjc/data/internals/WrappedOption.java @@ -11,7 +11,7 @@ import bjc.data.Option; * * @author Ben Culkin. * @param - * The wrapped type. + * The wrapped type. */ public class WrappedOption implements IHolder { /* The held value. */ @@ -21,16 +21,15 @@ public class WrappedOption implements IHolder { * Create a new wrapped option. * * @param seedValue - * The value to wrap. + * The value to wrap. */ public WrappedOption(final IHolder seedValue) { held = new Option<>(seedValue); } /* - * The dummy parameter is to ensure the compiler can pick the right - * method, because without this method erases to the same type as the - * public one. + * The dummy parameter is to ensure the compiler can pick the right method, + * because without this method erases to the same type as the public one. */ private WrappedOption(final IHolder> toHold, @SuppressWarnings("unused") final boolean dummy) { @@ -38,10 +37,12 @@ public class WrappedOption implements IHolder { } @Override - public IHolder bind(final Function> binder) { - final IHolder> newHolder = held.map((containedHolder) -> { + public IHolder + bind(final Function> binder) { + final IHolder> newHolder = held.map(containedHolder -> { return containedHolder.bind((containedValue) -> { - if(containedValue == null) return new Option<>(null); + if (containedValue == null) + return new Option<>(null); return binder.apply(containedValue); }); @@ -51,17 +52,20 @@ public class WrappedOption implements IHolder { } @Override - public Function> lift(final Function func) { - return (val) -> { + public Function> + lift(final Function func) { + return val -> { return new Option<>(func.apply(val)); }; } @Override - public IHolder map(final Function mapper) { - final IHolder> newHolder = held.map((containedHolder) -> { + public IHolder + map(final Function mapper) { + final IHolder> newHolder = held.map(containedHolder -> { return containedHolder.map((containedValue) -> { - if(containedValue == null) return null; + if (containedValue == null) + return null; return mapper.apply(containedValue); }); @@ -71,10 +75,12 @@ public class WrappedOption implements IHolder { } @Override - public IHolder transform(final UnaryOperator transformer) { - held.transform((containedHolder) -> { + public IHolder + transform(final UnaryOperator transformer) { + held.transform(containedHolder -> { return containedHolder.transform((containedValue) -> { - if(containedValue == null) return null; + if (containedValue == null) + return null; return transformer.apply(containedValue); }); @@ -84,10 +90,12 @@ public class WrappedOption implements IHolder { } @Override - public UnwrappedType unwrap(final Function unwrapper) { - return held.unwrap((containedHolder) -> { + public UnwrappedType + unwrap(final Function unwrapper) { + return held.unwrap(containedHolder -> { return containedHolder.unwrap((containedValue) -> { - if(containedValue == null) return null; + if (containedValue == null) + return null; return unwrapper.apply(containedValue); }); -- cgit v1.2.3