From df94066e3af02ff02d5ab4d033a3d603f743234c Mon Sep 17 00:00:00 2001 From: bjculkin Date: Mon, 12 Feb 2018 22:45:04 -0500 Subject: Formatting pass --- .../main/java/bjc/utils/data/BooleanToggle.java | 10 +- .../main/java/bjc/utils/data/CircularIterator.java | 17 ++-- base/src/main/java/bjc/utils/data/Either.java | 74 ++++++++------- .../java/bjc/utils/data/GeneratingIterator.java | 17 ++-- base/src/main/java/bjc/utils/data/IHolder.java | 53 +++++------ base/src/main/java/bjc/utils/data/IPair.java | 98 +++++++++----------- base/src/main/java/bjc/utils/data/ITree.java | 101 +++++++++------------ base/src/main/java/bjc/utils/data/Identity.java | 24 +++-- base/src/main/java/bjc/utils/data/LazyPair.java | 88 +++++++++--------- base/src/main/java/bjc/utils/data/ListHolder.java | 20 ++-- base/src/main/java/bjc/utils/data/Option.java | 24 ++--- base/src/main/java/bjc/utils/data/Pair.java | 42 ++++----- .../main/java/bjc/utils/data/SingleIterator.java | 4 +- .../main/java/bjc/utils/data/SingleSupplier.java | 15 ++- base/src/main/java/bjc/utils/data/Toggle.java | 10 +- .../bjc/utils/data/TopDownTransformIterator.java | 57 ++++++------ .../java/bjc/utils/data/TransformIterator.java | 8 +- base/src/main/java/bjc/utils/data/Tree.java | 92 +++++++++---------- base/src/main/java/bjc/utils/data/ValueToggle.java | 14 +-- .../java/bjc/utils/data/internals/BoundLazy.java | 24 ++--- .../bjc/utils/data/internals/BoundLazyPair.java | 49 +++++----- .../bjc/utils/data/internals/BoundListHolder.java | 15 ++- .../utils/data/internals/HalfBoundLazyPair.java | 28 +++--- .../java/bjc/utils/data/internals/WrappedLazy.java | 4 +- .../bjc/utils/data/internals/WrappedOption.java | 10 +- 25 files changed, 431 insertions(+), 467 deletions(-) (limited to 'base/src/main/java/bjc/utils/data') diff --git a/base/src/main/java/bjc/utils/data/BooleanToggle.java b/base/src/main/java/bjc/utils/data/BooleanToggle.java index 280b90d..542d2b6 100644 --- a/base/src/main/java/bjc/utils/data/BooleanToggle.java +++ b/base/src/main/java/bjc/utils/data/BooleanToggle.java @@ -21,7 +21,7 @@ public class BooleanToggle implements Toggle { * Create a flip-flop with the specified initial value. * * @param initial - * The initial value of the flip-flop. + * The initial value of the flip-flop. */ public BooleanToggle(final boolean initial) { val = initial; @@ -59,13 +59,13 @@ public class BooleanToggle implements Toggle { @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (!(obj instanceof BooleanToggle)) return false; + if(this == obj) return true; + if(obj == null) return false; + if(!(obj instanceof BooleanToggle)) return false; final BooleanToggle other = (BooleanToggle) obj; - if (val != other.val) return false; + if(val != other.val) return false; return true; } diff --git a/base/src/main/java/bjc/utils/data/CircularIterator.java b/base/src/main/java/bjc/utils/data/CircularIterator.java index 60f815c..507ee01 100644 --- a/base/src/main/java/bjc/utils/data/CircularIterator.java +++ b/base/src/main/java/bjc/utils/data/CircularIterator.java @@ -8,7 +8,7 @@ import java.util.Iterator; * @author EVE * * @param - * The type of the iterable. + * The type of the iterable. */ public class CircularIterator implements Iterator { /* The iterable, and our current iterator into it. */ @@ -28,11 +28,11 @@ public class CircularIterator implements Iterator { * Create a new circular iterator. * * @param src - * The iterable to iterate from. + * The iterable to iterate from. * * @param circ - * Should we actually do circular iteration, or just - * repeat the terminal element? + * Should we actually do circular iteration, or just repeat the + * terminal element? */ public CircularIterator(final Iterable src, final boolean circ) { source = src; @@ -45,7 +45,7 @@ public class CircularIterator implements Iterator { * Create a new circular iterator that does actual circular iteration. * * @param src - * The iterable to iterate from. + * The iterable to iterate from. */ public CircularIterator(final Iterable src) { this(src, true); @@ -59,10 +59,11 @@ public class CircularIterator implements Iterator { @Override public E next() { - if (!curr.hasNext()) { - if (doCircle) { + if(!curr.hasNext()) { + if(doCircle) { curr = source.iterator(); - } else return curElm; + } else + return curElm; } curElm = curr.next(); diff --git a/base/src/main/java/bjc/utils/data/Either.java b/base/src/main/java/bjc/utils/data/Either.java index 20a06f5..6023b60 100644 --- a/base/src/main/java/bjc/utils/data/Either.java +++ b/base/src/main/java/bjc/utils/data/Either.java @@ -9,10 +9,10 @@ import java.util.function.Function; * @author ben * * @param - * The type that could be on the left. + * The type that could be on the left. * * @param - * The type that could be on the right. + * The type that could be on the right. * */ public class Either implements IPair { @@ -20,16 +20,15 @@ public class Either implements IPair { * Create a new either with the left value occupied. * * @param - * The type of the left value. + * The type of the left value. * * @param - * The type of the empty right value. - * + * The type of the empty right value. + * * @param left - * The value to put on the left. + * The value to put on the left. * - * @return - * An either with the left side occupied. + * @return An either with the left side occupied. */ public static Either left(final LeftType left) { return new Either<>(left, null); @@ -39,16 +38,15 @@ public class Either implements IPair { * Create a new either with the right value occupied. * * @param - * The type of the empty left value. + * The type of the empty left value. * * @param - * The type of the right value. + * The type of the right value. * * @param right - * The value to put on the right. + * The value to put on the right. * - * @return - * An either with the right side occupied. + * @return An either with the right side occupied. */ public static Either right(final RightType right) { return new Either<>(null, right); @@ -63,7 +61,7 @@ public class Either implements IPair { /* Create a new either with specifed values. */ private Either(final LeftType left, final RightType right) { - if (left == null) { + if(left == null) { rightVal = right; } else { leftVal = left; @@ -75,7 +73,7 @@ public class Either implements IPair { @Override public IPair bind( final BiFunction> binder) { - if (binder == null) throw new NullPointerException("Binder must not be null"); + if(binder == null) throw new NullPointerException("Binder must not be null"); return binder.apply(leftVal, rightVal); } @@ -83,9 +81,9 @@ public class Either implements IPair { @Override public IPair bindLeft( final Function> leftBinder) { - if (leftBinder == null) throw new NullPointerException("Left binder must not be null"); + if(leftBinder == null) throw new NullPointerException("Left binder must not be null"); - if (isLeft) return leftBinder.apply(leftVal); + if(isLeft) return leftBinder.apply(leftVal); return new Either<>(null, rightVal); } @@ -93,9 +91,9 @@ public class Either implements IPair { @Override public IPair bindRight( final Function> rightBinder) { - if (rightBinder == null) throw new NullPointerException("Right binder must not be null"); + if(rightBinder == null) throw new NullPointerException("Right binder must not be null"); - if (isLeft) return new Either<>(leftVal, null); + if(isLeft) return new Either<>(leftVal, null); return rightBinder.apply(rightVal); } @@ -105,15 +103,15 @@ public class Either implements IPair { final IPair otherPair, final BiFunction leftCombiner, final BiFunction rightCombiner) { - if (otherPair == null) { + 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"); } - if (isLeft) { + if(isLeft) { return otherPair.bind((otherLeft, otherRight) -> { CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft); @@ -130,25 +128,25 @@ public class Either implements IPair { @Override public IPair mapLeft(final Function mapper) { - if (mapper == null) throw new NullPointerException("Mapper must not be null"); + if(mapper == null) throw new NullPointerException("Mapper must not be null"); - if (isLeft) return new Either<>(mapper.apply(leftVal), null); + if(isLeft) return new Either<>(mapper.apply(leftVal), null); return new Either<>(null, rightVal); } @Override public IPair mapRight(final Function mapper) { - if (mapper == null) throw new NullPointerException("Mapper must not be null"); + if(mapper == null) throw new NullPointerException("Mapper must not be null"); - if (isLeft) return new Either<>(leftVal, null); + if(isLeft) return new Either<>(leftVal, null); return new Either<>(null, mapper.apply(rightVal)); } @Override public MergedType merge(final BiFunction merger) { - if (merger == null) throw new NullPointerException("Merger must not be null"); + if(merger == null) throw new NullPointerException("Merger must not be null"); return merger.apply(leftVal, rightVal); } @@ -167,21 +165,21 @@ public class Either implements IPair { @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (!(obj instanceof Either)) return false; + if(this == obj) return true; + if(obj == null) return false; + if(!(obj instanceof Either)) return false; final Either other = (Either) obj; - if (isLeft != other.isLeft) return false; + if(isLeft != other.isLeft) return false; - if (leftVal == null) { - if (other.leftVal != null) return false; - } else if (!leftVal.equals(other.leftVal)) return false; + if(leftVal == null) { + if(other.leftVal != null) return false; + } else if(!leftVal.equals(other.leftVal)) return false; - if (rightVal == null) { - if (other.rightVal != null) return false; - } else if (!rightVal.equals(other.rightVal)) return false; + if(rightVal == null) { + if(other.rightVal != null) return false; + } else if(!rightVal.equals(other.rightVal)) return false; return true; } diff --git a/base/src/main/java/bjc/utils/data/GeneratingIterator.java b/base/src/main/java/bjc/utils/data/GeneratingIterator.java index 92d10a5..8e6bcd2 100644 --- a/base/src/main/java/bjc/utils/data/GeneratingIterator.java +++ b/base/src/main/java/bjc/utils/data/GeneratingIterator.java @@ -10,7 +10,7 @@ import java.util.function.UnaryOperator; * @author bjculkin * * @param - * The type of element generated. + * The type of element generated. */ public class GeneratingIterator implements Iterator { /* Our current state. */ @@ -24,14 +24,14 @@ public class GeneratingIterator implements Iterator { * Create a new generative iterator. * * @param initial - * The initial state of the generator. + * The initial state of the generator. * * @param transition - * The function to apply to the state. + * The function to apply to the state. * * @param stopper - * The predicate applied to the current state to - * determine when to stop. + * The predicate applied to the current state to determine when + * to stop. */ public GeneratingIterator(E initial, UnaryOperator transition, Predicate stopper) { state = initial; @@ -45,10 +45,9 @@ public class GeneratingIterator implements Iterator { } /* - * @NOTE - * As this currently is, it only works correctly assuming that - * next() is only called when hasNext() is true. Should we - * safeguard against people who are not doing the right thing? + * @NOTE As this currently is, it only works correctly assuming that + * next() is only called when hasNext() is true. Should we safeguard + * against people who are not doing the right thing? */ @Override public E next() { diff --git a/base/src/main/java/bjc/utils/data/IHolder.java b/base/src/main/java/bjc/utils/data/IHolder.java index 0b0cfd2..4d2ed2c 100644 --- a/base/src/main/java/bjc/utils/data/IHolder.java +++ b/base/src/main/java/bjc/utils/data/IHolder.java @@ -16,20 +16,19 @@ import bjc.utils.funcdata.theory.Functor; * @author ben * * @param - * The type of value held. + * The type of value held. */ public interface IHolder extends Functor { /** * Bind a function across the value in this container. * * @param - * The type of value in this container. + * The type of value in this container. * * @param binder - * The function to bind to the value. + * The function to bind to the value. * - * @return - * A holder from binding the value. + * @return A holder from binding the value. */ public IHolder bind(Function> binder); @@ -37,7 +36,7 @@ public interface IHolder extends Functor { * Apply an action to the value. * * @param action - * The action to apply to the value. + * The action to apply to the value. */ public default void doWith(final Consumer action) { transform(value -> { @@ -51,7 +50,7 @@ public interface IHolder extends Functor { default Function, Functor> fmap( final Function func) { return argumentFunctor -> { - if (!(argumentFunctor instanceof IHolder)) { + if(!(argumentFunctor instanceof IHolder)) { final String msg = "This functor only supports mapping over instances of IHolder"; throw new IllegalArgumentException(msg); @@ -72,21 +71,19 @@ public interface IHolder extends Functor { * Lifts a function to bind over this holder. * * @param - * The type of the functions return. + * The type of the functions return. * * @param func - * The function to lift over the holder. + * The function to lift over the holder. * - * @return - * The function lifted over the holder. + * @return The function lifted over the holder. */ public Function> lift(Function func); /** * Make this holder lazy. * - * @return - * A lazy version of this holder. + * @return A lazy version of this holder. */ public default IHolder makeLazy() { return new WrappedLazy<>(this); @@ -95,8 +92,7 @@ public interface IHolder extends Functor { /** * Make this holder a list. * - * @return - * A list version of this holder. + * @return A list version of this holder. */ public default IHolder makeList() { return new BoundListHolder<>(new FunctionalList<>(this)); @@ -105,8 +101,7 @@ public interface IHolder extends Functor { /** * Make this holder optional. * - * @return - * An optional version of this holder. + * @return An optional version of this holder. */ public default IHolder makeOptional() { return new WrappedOption<>(this); @@ -119,13 +114,12 @@ public interface IHolder extends Functor { * Does not change the internal state of this holder. * * @param - * The type of the mapped value. + * The type of the mapped value. * * @param mapper - * The function to do mapping with. + * The function to do mapping with. * - * @return - * A holder with the mapped value + * @return A holder with the mapped value */ public IHolder map(Function mapper); @@ -133,10 +127,9 @@ public interface IHolder extends Functor { * Replace the held value with a new one. * * @param newValue - * The value to hold instead. + * The value to hold instead. * - * @return - * The holder itself. + * @return The holder itself. */ public default IHolder replace(final ContainedType newValue) { return transform(oldValue -> { @@ -148,10 +141,9 @@ public interface IHolder extends Functor { * Transform the value held in this holder. * * @param transformer - * The function to transform the value with. + * The function to transform the value with. * - * @return - * The holder itself, for easy chaining. + * @return The holder itself, for easy chaining. */ public IHolder transform(UnaryOperator transformer); @@ -160,13 +152,12 @@ public interface IHolder extends Functor { * held. * * @param - * The type of the unwrapped value. + * The type of the unwrapped value. * * @param unwrapper - * The function to use to unwrap the value. + * The function to use to unwrap the value. * - * @return - * The unwrapped held value. + * @return The unwrapped held value. */ public UnwrappedType unwrap(Function unwrapper); } diff --git a/base/src/main/java/bjc/utils/data/IPair.java b/base/src/main/java/bjc/utils/data/IPair.java index 75b092d..1c864d1 100644 --- a/base/src/main/java/bjc/utils/data/IPair.java +++ b/base/src/main/java/bjc/utils/data/IPair.java @@ -12,10 +12,10 @@ import bjc.utils.funcdata.theory.Bifunctor; * @author ben * * @param - * The type of the left side of the pair. + * The type of the left side of the pair. * * @param - * The type of the right side of the pair. + * The type of the right side of the pair. * */ public interface IPair extends Bifunctor { @@ -23,16 +23,15 @@ public interface IPair extends Bifunctor - * The type of the bound left. + * The type of the bound left. * * @param - * The type of the bound right. + * The type of the bound right. * * @param binder - * The function to bind with. + * The function to bind with. * - * @return - * The bound pair. + * @return The bound pair. */ public IPair bind( BiFunction> binder); @@ -41,13 +40,12 @@ public interface IPair extends Bifunctor - * The type of the bound value. + * The type of the bound value. * * @param leftBinder - * The function to use to bind. + * The function to use to bind. * - * @return - * A pair with the left type bound. + * @return A pair with the left type bound. */ public IPair bindLeft( Function> leftBinder); @@ -56,13 +54,12 @@ public interface IPair extends Bifunctor - * The type of the bound value. + * The type of the bound value. * * @param rightBinder - * The function to use to bind. + * The function to use to bind. * - * @return - * A pair with the right type bound. + * @return A pair with the right type bound. */ public IPair bindRight( Function> rightBinder); @@ -71,16 +68,15 @@ public interface IPair extends Bifunctor - * The left type of the other pair. + * The left type of the other pair. * * @param - * The right type of the other pair. + * The right type of the other pair. * * @param otherPair - * The pair to combine with. + * The pair to combine with. * - * @return - * The pairs, pairwise combined together. + * @return The pairs, pairwise combined together. */ public default IPair, IPair> combine( final IPair otherPair) { @@ -91,28 +87,27 @@ public interface IPair extends Bifunctor - * The type of the left value of the other pair. + * The type of the left value of the other pair. * * @param - * The type of the right value of the other pair. + * The type of the right value of the other pair. * * @param - * The type of the left value of the combined pair. + * The type of the left value of the combined pair. * * @param - * The type of the right value of the combined pair. + * The type of the right value of the combined pair. * * @param otherPair - * The other pair to combine with. + * The other pair to combine with. * * @param leftCombiner - * The function to combine the left values with. + * The function to combine the left values with. * * @param rightCombiner - * The function to combine the right values with. + * The function to combine the right values with. * - * @return - * A pair with its values combined. + * @return A pair with its values combined. */ public IPair combine( IPair otherPair, @@ -124,7 +119,7 @@ public interface IPair extends Bifunctor consumer) { merge((leftValue, rightValue) -> { @@ -135,10 +130,10 @@ public interface IPair extends Bifunctor LeftBifunctorMap - fmapLeft(final Function func) { + default LeftBifunctorMap fmapLeft( + final Function func) { return argumentPair -> { - if (!(argumentPair instanceof IPair)) { + if(!(argumentPair instanceof IPair)) { final String msg = "This function can only be applied to instances of IPair"; throw new IllegalArgumentException(msg); @@ -151,10 +146,10 @@ public interface IPair extends Bifunctor RightBifunctorMap - fmapRight(final Function func) { + default RightBifunctorMap fmapRight( + final Function func) { return argumentPair -> { - if (!(argumentPair instanceof IPair)) { + if(!(argumentPair instanceof IPair)) { final String msg = "This function can only be applied to instances of IPair"; throw new IllegalArgumentException(msg); @@ -169,8 +164,7 @@ public interface IPair extends Bifunctor extends Bifunctor extends Bifunctor - * The new type of the left part of the pair. + * The new type of the left part of the pair. * * @param mapper - * The function to use to transform the left part of the - * pair. + * The function to use to transform the left part of the pair. * - * @return - * The pair, with its left part transformed. + * @return The pair, with its left part transformed. */ public IPair mapLeft(Function mapper); @@ -211,14 +202,12 @@ public interface IPair extends Bifunctor - * The new type of the right part of the pair. + * The new type of the right part of the pair. * * @param mapper - * The function to use to transform the right part of the - * pair. + * The function to use to transform the right part of the pair. * - * @return - * The pair, with its right part transformed. + * @return The pair, with its right part transformed. */ public IPair mapRight(Function mapper); @@ -226,13 +215,12 @@ public interface IPair extends Bifunctor - * The type of the single value. + * The type of the single value. * * @param merger - * The function to use for merging. + * The function to use for merging. * - * @return - * The pair, merged into a single value. + * @return The pair, merged into a single value. */ public MergedType merge(BiFunction merger); } diff --git a/base/src/main/java/bjc/utils/data/ITree.java b/base/src/main/java/bjc/utils/data/ITree.java index 450905b..5a4d645 100644 --- a/base/src/main/java/bjc/utils/data/ITree.java +++ b/base/src/main/java/bjc/utils/data/ITree.java @@ -14,7 +14,7 @@ import bjc.utils.functypes.ListFlattener; * @author ben * * @param - * The type of data contained in the tree nodes. + * The type of data contained in the tree nodes. * */ public interface ITree { @@ -22,7 +22,7 @@ public interface ITree { * Append a child to this node. * * @param child - * The child to append to this node. + * The child to append to this node. */ void addChild(ITree child); @@ -30,7 +30,7 @@ public interface ITree { * Prepend a child to this node. * * @param child - * The child to prepend to this node. + * The child to prepend to this node. */ void prependChild(ITree child); @@ -38,24 +38,23 @@ public interface ITree { * Collapse a tree into a single version. * * @param - * The intermediate type being folded. + * The intermediate type being folded. * * @param - * The type that is the end result. + * The type that is the end result. * * @param leafTransform - * The function to use to convert leaf values. + * The function to use to convert leaf values. * * @param nodeCollapser - * The function to use to convert internal nodes and - * their children. + * The function to use to convert internal nodes and their + * children. * * @param resultTransformer - * The function to use to convert a state to the returned - * version. + * The function to use to convert a state to the returned + * version. * - * @return - * The final transformed state. + * @return The final transformed state. */ ReturnedType collapse(Function leafTransform, Function> nodeCollapser, @@ -65,7 +64,7 @@ public interface ITree { * Execute a given action for each of this tree's children. * * @param action - * The action to execute for each child. + * The action to execute for each child. */ void doForChildren(Consumer> action); @@ -74,14 +73,13 @@ public interface ITree { * those trees into a single tree. * * @param mapper - * The function to use to map values into trees. + * The function to use to map values into trees. * - * @return - * A tree, with some nodes expanded into trees. + * @return A tree, with some nodes expanded into trees. */ default ITree flatMapTree(final Function> mapper) { return topDownTransform(dat -> TopDownTransformResult.PUSHDOWN, node -> { - if (node.getChildrenCount() > 0) { + if(node.getChildrenCount() > 0) { final ITree parent = node.transformHead(mapper); node.doForChildren(parent::addChild); @@ -97,10 +95,9 @@ public interface ITree { * Get the specified child of this tree. * * @param childNo - * The number of the child to get. + * The number of the child to get. * - * @return - * The specified child of this tree. + * @return The specified child of this tree. */ default ITree getChild(final int childNo) { return transformChild(childNo, child -> child); @@ -109,16 +106,14 @@ public interface ITree { /** * Get a count of the number of direct children this node has. * - * @return - * The number of direct children this node has. + * @return The number of direct children this node has. */ int getChildrenCount(); /** * Get the data stored in this node. * - * @return - * The data stored in this node. + * @return The data stored in this node. */ default ContainedType getHead() { return transformHead(head -> head); @@ -128,16 +123,15 @@ public interface ITree { * Rebuild the tree with the same structure, but different nodes. * * @param - * The type of the new tree. + * The type of the new tree. * * @param leafTransformer - * The function to use to transform leaf tokens. + * The function to use to transform leaf tokens. * * @param internalTransformer - * The function to use to transform internal tokens. + * The function to use to transform internal tokens. * - * @return - * The tree, with the nodes changed. + * @return The tree, with the nodes changed. */ ITree rebuildTree(Function leafTransformer, Function internalTransformer); @@ -146,10 +140,10 @@ public interface ITree { * Transform some of the nodes in this tree. * * @param nodePicker - * The predicate to use to pick nodes to transform. + * The predicate to use to pick nodes to transform. * * @param transformer - * The function to use to transform picked nodes. + * The function to use to transform picked nodes. */ void selectiveTransform(Predicate nodePicker, UnaryOperator transformer); @@ -157,13 +151,12 @@ public interface ITree { * Do a top-down transform of the tree. * * @param transformPicker - * The function to use to pick how to progress. + * The function to use to pick how to progress. * * @param transformer - * The function used to transform picked subtrees. + * The function used to transform picked subtrees. * - * @return - * The tree with the transform applied to picked subtrees. + * @return The tree with the transform applied to picked subtrees. */ ITree topDownTransform(Function transformPicker, UnaryOperator> transformer); @@ -172,20 +165,19 @@ public interface ITree { * Transform one of this nodes children. * * @param - * The type of the transformed value. + * The type of the transformed value. * * @param childNo - * The number of the child to transform. + * The number of the child to transform. * * @param transformer - * The function to use to transform the value. + * The function to use to transform the value. * - * @return - * The transformed value. + * @return The transformed value. * * @throws IllegalArgumentException - * if the childNo is out of bounds (0 <= childNo <= - * childCount()). + * if the childNo is out of bounds (0 <= childNo <= + * childCount()). */ TransformedType transformChild(int childNo, Function, TransformedType> transformer); @@ -194,13 +186,12 @@ public interface ITree { * Transform the value that is the head of this node. * * @param - * The type of the transformed value. + * The type of the transformed value. * * @param transformer - * The function to use to transform the value. + * The function to use to transform the value. * - * @return - * The transformed value. + * @return The transformed value. */ TransformedType transformHead(Function transformer); @@ -208,13 +199,12 @@ public interface ITree { * Transform the tree into a tree with a different type of token. * * @param - * The type of the new tree. + * The type of the new tree. * * @param transformer - * The function to use to transform tokens. + * The function to use to transform tokens. * - * @return - * A tree with the token types transformed. + * @return A tree with the token types transformed. */ default ITree transformTree(final Function transformer) { return rebuildTree(transformer, transformer); @@ -224,10 +214,10 @@ public interface ITree { * Perform an action on each part of the tree. * * @param linearizationMethod - * The way to traverse the tree. + * The way to traverse the tree. * * @param action - * The action to perform on each tree node. + * The action to perform on each tree node. */ void traverse(TreeLinearizationMethod linearizationMethod, Consumer action); @@ -235,11 +225,10 @@ public interface ITree { * Find the farthest to right child that satisfies the given predicate. * * @param childPred - * The predicate to satisfy. + * The predicate to satisfy. * - * @return - * The index of the right-most child that satisfies the predicate, - * or -1 if one doesn't exist. + * @return The index of the right-most child that satisfies the + * predicate, or -1 if one doesn't exist. */ int revFind(Predicate> childPred); } diff --git a/base/src/main/java/bjc/utils/data/Identity.java b/base/src/main/java/bjc/utils/data/Identity.java index 3acb5aa..44ddc31 100644 --- a/base/src/main/java/bjc/utils/data/Identity.java +++ b/base/src/main/java/bjc/utils/data/Identity.java @@ -9,7 +9,7 @@ import java.util.function.UnaryOperator; * @author ben * * @param - * The type contained in the holder. + * The type contained in the holder. */ public class Identity implements IHolder { /* The held value. */ @@ -24,7 +24,7 @@ public class Identity implements IHolder { * Create a holder holding the specified value. * * @param value - * The value to hold. + * The value to hold. */ public Identity(final ContainedType value) { heldValue = value; @@ -47,15 +47,15 @@ public class Identity implements IHolder { @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (!(obj instanceof Identity)) return false; + if(this == obj) return true; + if(obj == null) return false; + if(!(obj instanceof Identity)) return false; final Identity other = (Identity) obj; - if (heldValue == null) { - if (other.heldValue != null) return false; - } else if (!heldValue.equals(other.heldValue)) return false; + if(heldValue == null) { + if(other.heldValue != null) return false; + } else if(!heldValue.equals(other.heldValue)) return false; return true; } @@ -93,10 +93,9 @@ public class Identity implements IHolder { * Create a new identity container. * * @param val - * The contained value. + * The contained value. * - * @return - * A new identity container. + * @return A new identity container. */ public static Identity id(final ContainedType val) { return new Identity<>(val); @@ -105,8 +104,7 @@ public class Identity implements IHolder { /** * Create a new empty identity container. * - * @return - * A new empty identity container. + * @return A new empty identity container. */ public static Identity id() { return new Identity<>(); diff --git a/base/src/main/java/bjc/utils/data/LazyPair.java b/base/src/main/java/bjc/utils/data/LazyPair.java index 548a09e..0500486 100644 --- a/base/src/main/java/bjc/utils/data/LazyPair.java +++ b/base/src/main/java/bjc/utils/data/LazyPair.java @@ -13,40 +13,40 @@ import bjc.utils.data.internals.HalfBoundLazyPair; * @author ben * * @param - * The type on the left side of the pair. + * The type on the left side of the pair. * * @param - * The type on the right side of the pair. + * The type on the right side of the pair. */ public class LazyPair implements IPair { /* The supplier for the left value. */ - private Supplier leftSupplier; + private Supplier leftSupplier; /* The left value. */ private LeftType leftValue; /* Whether the left value has been created. */ - private boolean leftMaterialized; + private boolean leftMaterialized; /* The supplier for the right value. */ private Supplier rightSupplier; /* The right value. */ private RightType rightValue; /* Whether the right value has been created. */ - private boolean rightMaterialized; + private boolean rightMaterialized; /** * Create a new lazy pair, using the set values. * * @param leftVal - * The value for the left side of the pair. + * The value for the left side of the pair. * * @param rightVal - * The value for the right side of the pair. + * The value for the right side of the pair. */ public LazyPair(final LeftType leftVal, final RightType rightVal) { - leftValue = leftVal; + leftValue = leftVal; rightValue = rightVal; - leftMaterialized = true; + leftMaterialized = true; rightMaterialized = true; } @@ -54,17 +54,17 @@ public class LazyPair implements IPair * Create a new lazy pair from the given value sources. * * @param leftSupp - * The source for a value on the left side of the pair. + * The source for a value on the left side of the pair. * * @param rightSupp - * The source for a value on the right side of the pair. + * The source for a value on the right side of the pair. */ public LazyPair(final Supplier leftSupp, final Supplier rightSupp) { /* Use single suppliers to catch double-instantiation bugs. */ - leftSupplier = new SingleSupplier<>(leftSupp); + leftSupplier = new SingleSupplier<>(leftSupp); rightSupplier = new SingleSupplier<>(rightSupp); - leftMaterialized = false; + leftMaterialized = false; rightMaterialized = false; } @@ -78,7 +78,7 @@ public class LazyPair implements IPair public IPair bindLeft( final Function> leftBinder) { final Supplier leftSupp = () -> { - if (leftMaterialized) return leftValue; + if(leftMaterialized) return leftValue; return leftSupplier.get(); }; @@ -90,7 +90,7 @@ public class LazyPair implements IPair public IPair bindRight( final Function> rightBinder) { final Supplier rightSupp = () -> { - if (rightMaterialized) return rightValue; + if(rightMaterialized) return rightValue; return rightSupplier.get(); }; @@ -105,7 +105,7 @@ public class LazyPair implements IPair final BiFunction rightCombiner) { return otherPair.bind((otherLeft, otherRight) -> { return bind((leftVal, rightVal) -> { - final CombinedLeft left = leftCombiner.apply(leftVal, otherLeft); + final CombinedLeft left = leftCombiner.apply(leftVal, otherLeft); final CombinedRight right = rightCombiner.apply(rightVal, otherRight); return new LazyPair<>(left, right); @@ -115,7 +115,7 @@ public class LazyPair implements IPair @Override public LeftType getLeft() { - if (!leftMaterialized) { + if(!leftMaterialized) { leftValue = leftSupplier.get(); leftMaterialized = true; @@ -126,7 +126,7 @@ public class LazyPair implements IPair @Override public RightType getRight() { - if (!rightMaterialized) { + if(!rightMaterialized) { rightValue = rightSupplier.get(); rightMaterialized = true; @@ -138,13 +138,13 @@ public class LazyPair implements IPair @Override public IPair mapLeft(final Function mapper) { final Supplier leftSupp = () -> { - if (leftMaterialized) return mapper.apply(leftValue); + if(leftMaterialized) return mapper.apply(leftValue); return mapper.apply(leftSupplier.get()); }; final Supplier rightSupp = () -> { - if (rightMaterialized) return rightValue; + if(rightMaterialized) return rightValue; return rightSupplier.get(); }; @@ -155,13 +155,13 @@ public class LazyPair implements IPair @Override public IPair mapRight(final Function mapper) { final Supplier leftSupp = () -> { - if (leftMaterialized) return leftValue; + if(leftMaterialized) return leftValue; return leftSupplier.get(); }; final Supplier rightSupp = () -> { - if (rightMaterialized) return mapper.apply(rightValue); + if(rightMaterialized) return mapper.apply(rightValue); return mapper.apply(rightSupplier.get()); }; @@ -171,13 +171,13 @@ public class LazyPair implements IPair @Override public MergedType merge(final BiFunction merger) { - if (!leftMaterialized) { + if(!leftMaterialized) { leftValue = leftSupplier.get(); leftMaterialized = true; } - if (!rightMaterialized) { + if(!rightMaterialized) { rightValue = rightSupplier.get(); rightMaterialized = true; @@ -191,13 +191,13 @@ public class LazyPair implements IPair String leftVal; String rightVal; - if (leftMaterialized) { + if(leftMaterialized) { leftVal = leftValue.toString(); } else { leftVal = "(un-materialized)"; } - if (rightMaterialized) { + if(rightMaterialized) { rightVal = rightValue.toString(); } else { rightVal = "(un-materialized)"; @@ -221,26 +221,28 @@ public class LazyPair implements IPair @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (!(obj instanceof LazyPair)) return false; + if(this == obj) return true; + if(obj == null) return false; + if(!(obj instanceof LazyPair)) return false; final LazyPair other = (LazyPair) obj; - if (leftMaterialized != other.leftMaterialized) return false; - - if (leftMaterialized) { - if (leftValue == null) { - if (other.leftValue != null) return false; - } else if (!leftValue.equals(other.leftValue)) return false; - } else return false; - - if (rightMaterialized != other.rightMaterialized) return false; - if (rightMaterialized) { - if (rightValue == null) { - if (other.rightValue != null) return false; - } else if (!rightValue.equals(other.rightValue)) return false; - } else return false; + if(leftMaterialized != other.leftMaterialized) return false; + + if(leftMaterialized) { + if(leftValue == null) { + if(other.leftValue != null) return false; + } else if(!leftValue.equals(other.leftValue)) return false; + } else + return false; + + if(rightMaterialized != other.rightMaterialized) return false; + if(rightMaterialized) { + if(rightValue == null) { + if(other.rightValue != null) return false; + } else if(!rightValue.equals(other.rightValue)) return false; + } else + return false; return true; } diff --git a/base/src/main/java/bjc/utils/data/ListHolder.java b/base/src/main/java/bjc/utils/data/ListHolder.java index 4564466..dbcdf6e 100644 --- a/base/src/main/java/bjc/utils/data/ListHolder.java +++ b/base/src/main/java/bjc/utils/data/ListHolder.java @@ -13,7 +13,7 @@ import bjc.utils.funcdata.IList; * @author ben * * @param - * The type of contained value. + * The type of contained value. */ public class ListHolder implements IHolder { private IList heldValues; @@ -22,14 +22,14 @@ public class ListHolder implements IHolder { * Create a new list holder. * * @param values - * The possible values for the computation. + * The possible values for the computation. */ @SafeVarargs public ListHolder(final ContainedType... values) { heldValues = new FunctionalList<>(); - if (values != null) { - for (final ContainedType containedValue : values) { + if(values != null) { + for(final ContainedType containedValue : values) { heldValues.add(containedValue); } } @@ -90,15 +90,15 @@ public class ListHolder implements IHolder { @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (!(obj instanceof ListHolder)) return false; + if(this == obj) return true; + if(obj == null) return false; + if(!(obj instanceof ListHolder)) return false; final ListHolder other = (ListHolder) obj; - if (heldValues == null) { - if (other.heldValues != null) return false; - } else if (!heldValues.equals(other.heldValues)) return false; + if(heldValues == null) { + if(other.heldValues != null) return false; + } else if(!heldValues.equals(other.heldValues)) return false; return true; } diff --git a/base/src/main/java/bjc/utils/data/Option.java b/base/src/main/java/bjc/utils/data/Option.java index 6eae21f..7869946 100644 --- a/base/src/main/java/bjc/utils/data/Option.java +++ b/base/src/main/java/bjc/utils/data/Option.java @@ -9,7 +9,7 @@ import java.util.function.UnaryOperator; * @author ben * * @param - * The type of the value that may or may not be held. + * The type of the value that may or may not be held. */ public class Option implements IHolder { private ContainedType held; @@ -18,7 +18,7 @@ public class Option implements IHolder { * Create a new optional, using the given initial value. * * @param seed - * The initial value for the optional. + * The initial value for the optional. */ public Option(final ContainedType seed) { held = seed; @@ -26,7 +26,7 @@ public class Option implements IHolder { @Override public IHolder bind(final Function> binder) { - if (held == null) return new Option<>(null); + if(held == null) return new Option<>(null); return binder.apply(held); } @@ -40,14 +40,14 @@ public class Option implements IHolder { @Override public IHolder map(final Function mapper) { - if (held == null) return new Option<>(null); + if(held == null) return new Option<>(null); return new Option<>(mapper.apply(held)); } @Override public IHolder transform(final UnaryOperator transformer) { - if (held != null) { + if(held != null) { held = transformer.apply(held); } @@ -56,7 +56,7 @@ public class Option implements IHolder { @Override public UnwrappedType unwrap(final Function unwrapper) { - if (held == null) return null; + if(held == null) return null; return unwrapper.apply(held); } @@ -78,15 +78,15 @@ public class Option implements IHolder { @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (!(obj instanceof Option)) return false; + if(this == obj) return true; + if(obj == null) return false; + if(!(obj instanceof Option)) return false; final Option other = (Option) obj; - if (held == null) { - if (other.held != null) return false; - } else if (!held.equals(other.held)) return false; + if(held == null) { + if(other.held != null) return false; + } else if(!held.equals(other.held)) return false; return true; } diff --git a/base/src/main/java/bjc/utils/data/Pair.java b/base/src/main/java/bjc/utils/data/Pair.java index fb81e17..40e4849 100644 --- a/base/src/main/java/bjc/utils/data/Pair.java +++ b/base/src/main/java/bjc/utils/data/Pair.java @@ -9,10 +9,10 @@ import java.util.function.Function; * @author ben * * @param - * The type of the left value. + * The type of the left value. * * @param - * The type of the right value. + * The type of the right value. */ public class Pair implements IPair { /* The left value. */ @@ -29,20 +29,20 @@ public class Pair implements IPair { * Create a new pair with both sides set to the specified values. * * @param left - * The value of the left side. + * The value of the left side. * * @param right - * The value of the right side. + * The value of the right side. */ public Pair(final LeftType left, final RightType right) { - leftValue = left; + leftValue = left; rightValue = right; } @Override public IPair bind( final BiFunction> binder) { - if (binder == null) throw new NullPointerException("Binder must not be null."); + if(binder == null) throw new NullPointerException("Binder must not be null."); return binder.apply(leftValue, rightValue); } @@ -50,7 +50,7 @@ public class Pair implements IPair { @Override public IPair bindLeft( final Function> leftBinder) { - if (leftBinder == null) throw new NullPointerException("Binder must not be null"); + if(leftBinder == null) throw new NullPointerException("Binder must not be null"); return leftBinder.apply(leftValue); } @@ -58,7 +58,7 @@ public class Pair implements IPair { @Override public IPair bindRight( final Function> rightBinder) { - if (rightBinder == null) throw new NullPointerException("Binder must not be null"); + if(rightBinder == null) throw new NullPointerException("Binder must not be null"); return rightBinder.apply(rightValue); } @@ -69,7 +69,7 @@ public class Pair implements IPair { final BiFunction leftCombiner, final BiFunction rightCombiner) { return otherPair.bind((otherLeft, otherRight) -> { - final CombinedLeft left = leftCombiner.apply(leftValue, otherLeft); + final CombinedLeft left = leftCombiner.apply(leftValue, otherLeft); final CombinedRight right = rightCombiner.apply(rightValue, otherRight); return new Pair<>(left, right); @@ -78,21 +78,21 @@ public class Pair implements IPair { @Override public IPair mapLeft(final Function mapper) { - if (mapper == null) throw new NullPointerException("Mapper must not be null"); + if(mapper == null) throw new NullPointerException("Mapper must not be null"); return new Pair<>(mapper.apply(leftValue), rightValue); } @Override public IPair mapRight(final Function mapper) { - if (mapper == null) throw new NullPointerException("Mapper must not be null"); + if(mapper == null) throw new NullPointerException("Mapper must not be null"); return new Pair<>(leftValue, mapper.apply(rightValue)); } @Override public MergedType merge(final BiFunction merger) { - if (merger == null) throw new NullPointerException("Merger must not be null"); + if(merger == null) throw new NullPointerException("Merger must not be null"); return merger.apply(leftValue, rightValue); } @@ -115,19 +115,19 @@ public class Pair implements IPair { @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (!(obj instanceof Pair)) return false; + if(this == obj) return true; + if(obj == null) return false; + if(!(obj instanceof Pair)) return false; final Pair other = (Pair) obj; - if (leftValue == null) { - if (other.leftValue != null) return false; - } else if (!leftValue.equals(other.leftValue)) return false; + if(leftValue == null) { + if(other.leftValue != null) return false; + } else if(!leftValue.equals(other.leftValue)) return false; - if (rightValue == null) { - if (other.rightValue != null) return false; - } else if (!rightValue.equals(other.rightValue)) return false; + if(rightValue == null) { + if(other.rightValue != null) return false; + } else if(!rightValue.equals(other.rightValue)) return false; return true; } diff --git a/base/src/main/java/bjc/utils/data/SingleIterator.java b/base/src/main/java/bjc/utils/data/SingleIterator.java index 1241a68..561cd0b 100644 --- a/base/src/main/java/bjc/utils/data/SingleIterator.java +++ b/base/src/main/java/bjc/utils/data/SingleIterator.java @@ -8,7 +8,7 @@ import java.util.Iterator; * @author EVE * * @param - * The type of the item. + * The type of the item. */ public class SingleIterator implements Iterator { /* The item being held. */ @@ -20,7 +20,7 @@ public class SingleIterator implements Iterator { * Create a iterator that yields a single item. * * @param item - * The item to yield. + * The item to yield. */ public SingleIterator(final T item) { itm = item; diff --git a/base/src/main/java/bjc/utils/data/SingleSupplier.java b/base/src/main/java/bjc/utils/data/SingleSupplier.java index 60f9136..8054d33 100644 --- a/base/src/main/java/bjc/utils/data/SingleSupplier.java +++ b/base/src/main/java/bjc/utils/data/SingleSupplier.java @@ -10,7 +10,7 @@ import java.util.function.Supplier; * @author ben * * @param - * The supplied type + * The supplied type */ public class SingleSupplier implements Supplier { /* The next supplier ID. */ @@ -25,10 +25,9 @@ public class SingleSupplier implements Supplier { /* * The place where the supplier was instantiated. * - * @NOTE - * This is both slow to create, and generally bad practice to keep - * exceptions around without throwing them. However, it is very - * useful to find where the first instantiation was. + * @NOTE This is both slow to create, and generally bad practice to keep + * exceptions around without throwing them. However, it is very useful + * to find where the first instantiation was. */ private Exception instSite; @@ -36,7 +35,7 @@ public class SingleSupplier implements Supplier { * Create a new single supplier from an existing value. * * @param supp - * The supplier to give a single value from. + * The supplier to give a single value from. */ public SingleSupplier(final Supplier supp) { source = supp; @@ -48,7 +47,7 @@ public class SingleSupplier implements Supplier { @Override public T get() { - if (gotten == true) { + if(gotten == true) { final String msg = String.format( "Attempted to retrieve value more than once from single supplier #%d", id); @@ -63,7 +62,7 @@ public class SingleSupplier implements Supplier { try { throw new IllegalStateException("Previous instantiation here."); - } catch (final IllegalStateException isex) { + } catch(final IllegalStateException isex) { instSite = isex; } diff --git a/base/src/main/java/bjc/utils/data/Toggle.java b/base/src/main/java/bjc/utils/data/Toggle.java index a1467e4..4e7b7d8 100644 --- a/base/src/main/java/bjc/utils/data/Toggle.java +++ b/base/src/main/java/bjc/utils/data/Toggle.java @@ -6,23 +6,21 @@ package bjc.utils.data; * @author EVE * * @param - * The value stored in the toggle. + * The value stored in the toggle. */ public interface Toggle { /** * Retrieve the currently-aligned value of this toggle, and swap the * value to the new one. * - * @return - * The previously-aligned value. + * @return The previously-aligned value. */ E get(); /** * Retrieve the currently-aligned value without altering the alignment. * - * @return - * The currently-aligned value. + * @return The currently-aligned value. */ E peek(); @@ -30,7 +28,7 @@ public interface Toggle { * Change the alignment of the toggle. * * @param isLeft - * Whether the toggle should be left-aligned or not. + * Whether the toggle should be left-aligned or not. */ void set(boolean isLeft); } diff --git a/base/src/main/java/bjc/utils/data/TopDownTransformIterator.java b/base/src/main/java/bjc/utils/data/TopDownTransformIterator.java index c6b7d31..8f3e40c 100644 --- a/base/src/main/java/bjc/utils/data/TopDownTransformIterator.java +++ b/base/src/main/java/bjc/utils/data/TopDownTransformIterator.java @@ -50,7 +50,7 @@ public class TopDownTransformIterator implements Iterator> src) { - if (curYield != null) { + if(curYield != null) { toYield.push(curYield); } @@ -63,51 +63,54 @@ public class TopDownTransformIterator implements Iterator flushYields(final ITree val) { - if (curYield != null) { + if(curYield != null) { toYield.add(new SingleIterator<>(val)); - if (curYield.hasNext()) + if(curYield.hasNext()) return curYield.next(); else { - while (toYield.size() != 0 && !curYield.hasNext()) { + while(toYield.size() != 0 && !curYield.hasNext()) { curYield = toYield.pop(); } - if (toYield.size() == 0 && !curYield.hasNext()) { + if(toYield.size() == 0 && !curYield.hasNext()) { curYield = null; return val; - } else return curYield.next(); + } else + return curYield.next(); } - } else return val; + } else + return val; } @Override public ITree next() { - if (done) throw new NoSuchElementException(); + if(done) throw new NoSuchElementException(); - if (curYield != null) { - if (curYield.hasNext()) + if(curYield != null) { + if(curYield.hasNext()) return curYield.next(); else { - while (toYield.size() != 0 && !curYield.hasNext()) { + while(toYield.size() != 0 && !curYield.hasNext()) { curYield = toYield.pop(); } - if (toYield.size() == 0 && !curYield.hasNext()) { + if(toYield.size() == 0 && !curYield.hasNext()) { curYield = null; - } else return curYield.next(); + } else + return curYield.next(); } } - if (initial) { + if(initial) { final TopDownTransformResult res = picker.apply(preParent.getHead()); - switch (res) { + switch(res) { case PASSTHROUGH: postParent = new Tree<>(preParent.getHead()); - if (preParent.getChildrenCount() != 0) { - for (int i = 0; i < preParent.getChildrenCount(); i++) { + if(preParent.getChildrenCount() != 0) { + for(int i = 0; i < preParent.getChildrenCount(); i++) { preChildren.add(preParent.getChild(i)); } @@ -127,8 +130,8 @@ public class TopDownTransformIterator implements Iterator implements Iterator(intRes.getHead()); - if (intRes.getChildrenCount() != 0) { - for (int i = 0; i < intRes.getChildrenCount(); i++) { + if(intRes.getChildrenCount() != 0) { + for(int i = 0; i < intRes.getChildrenCount(); i++) { preChildren.add(intRes.getChild(i)); } @@ -159,13 +162,13 @@ public class TopDownTransformIterator implements Iterator(picker, transform, preChildren.pop()); final ITree res = curChild.next(); @@ -176,12 +179,12 @@ public class TopDownTransformIterator implements Iterator res = null; - if (postParent == null) { + if(postParent == null) { res = new Tree<>(preParent.getHead()); System.out.println("\t\tTRACE: adding nodes " + postChildren + " to " + res); - for (final ITree child : postChildren) { + for(final ITree child : postChildren) { res.addChild(child); } @@ -191,7 +194,7 @@ public class TopDownTransformIterator implements Iterator child : postChildren) { + for(final ITree child : postChildren) { res.addChild(child); } } diff --git a/base/src/main/java/bjc/utils/data/TransformIterator.java b/base/src/main/java/bjc/utils/data/TransformIterator.java index 5a6ac85..9ce3b20 100644 --- a/base/src/main/java/bjc/utils/data/TransformIterator.java +++ b/base/src/main/java/bjc/utils/data/TransformIterator.java @@ -9,10 +9,10 @@ import java.util.function.Function; * @author EVE * * @param - * The source iterator type. + * The source iterator type. * * @param - * The destination iterator type. + * The destination iterator type. */ public class TransformIterator implements Iterator { /* Our source of values. */ @@ -24,10 +24,10 @@ public class TransformIterator implements Iterator { * Create a new transform iterator. * * @param source - * The source iterator to use. + * The source iterator to use. * * @param transform - * The transform to apply. + * The transform to apply. */ public TransformIterator(final Iterator source, final Function transform) { this.source = source; diff --git a/base/src/main/java/bjc/utils/data/Tree.java b/base/src/main/java/bjc/utils/data/Tree.java index 386153b..6b7e03a 100644 --- a/base/src/main/java/bjc/utils/data/Tree.java +++ b/base/src/main/java/bjc/utils/data/Tree.java @@ -16,7 +16,7 @@ import bjc.utils.functypes.ListFlattener; * @author ben * * @param - * The type contained in the tree. + * The type contained in the tree. */ public class Tree implements ITree { /* The data/label for this node. */ @@ -26,17 +26,16 @@ public class Tree implements ITree { private IList> children; /* Whether this node has children. */ - /* @NOTE - * Why have both this boolean and childCount? Why not just do a - * childCount == 0 - * whenever you'd check hasChildren? + /* + * @NOTE Why have both this boolean and childCount? Why not just do a + * childCount == 0 whenever you'd check hasChildren? */ private boolean hasChildren; /* The number of children this node has. */ - private int childCount = 0; + private int childCount = 0; /* The ID of this node. */ - private int ID; + private int ID; /* The next ID to assign to a node. */ private static int nextID = 0; @@ -44,7 +43,7 @@ public class Tree implements ITree { * Create a new leaf node in a tree. * * @param leaf - * The data to store as a leaf node. + * The data to store as a leaf node. */ public Tree(final ContainedType leaf) { data = leaf; @@ -58,10 +57,10 @@ public class Tree implements ITree { * Create a new tree node with the specified children. * * @param leaf - * The data to hold in this node. + * The data to hold in this node. * * @param childrn - * A list of children for this node. + * A list of children for this node. */ public Tree(final ContainedType leaf, final IList> childrn) { this(leaf); @@ -77,10 +76,10 @@ public class Tree implements ITree { * Create a new tree node with the specified children. * * @param leaf - * The data to hold in this node. + * The data to hold in this node. * * @param childrn - * A list of children for this node. + * A list of children for this node. */ @SafeVarargs public Tree(final ContainedType leaf, final ITree... childrn) { @@ -92,7 +91,7 @@ public class Tree implements ITree { children = new FunctionalList<>(); - for (final ITree child : childrn) { + for(final ITree child : childrn) { children.add(child); childCount++; @@ -101,7 +100,7 @@ public class Tree implements ITree { @Override public void addChild(final ITree child) { - if (hasChildren == false) { + if(hasChildren == false) { hasChildren = true; children = new FunctionalList<>(); @@ -114,7 +113,7 @@ public class Tree implements ITree { @Override public void prependChild(final ITree child) { - if (hasChildren == false) { + if(hasChildren == false) { hasChildren = true; children = new FunctionalList<>(); @@ -127,7 +126,7 @@ public class Tree implements ITree { @Override public void doForChildren(final Consumer> action) { - if (childCount > 0) { + if(childCount > 0) { children.forEach(action); } } @@ -139,11 +138,11 @@ public class Tree implements ITree { @Override public int revFind(final Predicate> childPred) { - if (childCount == 0) { + if(childCount == 0) { return -1; } else { - for (int i = childCount - 1; i >= 0; i--) { - if (childPred.test(getChild(i))) return i; + for(int i = childCount - 1; i >= 0; i--) { + if(childPred.test(getChild(i))) return i; } return -1; @@ -152,10 +151,10 @@ public class Tree implements ITree { @Override public void traverse(final TreeLinearizationMethod linearizationMethod, final Consumer action) { - if (hasChildren) { - switch (linearizationMethod) { + if(hasChildren) { + switch(linearizationMethod) { case INORDER: - if (childCount != 2) { + if(childCount != 2) { final String msg = "Can only do in-order traversal for binary trees."; throw new IllegalArgumentException(msg); @@ -195,7 +194,7 @@ public class Tree implements ITree { @Override public ITree flatMapTree(final Function> mapper) { - if (hasChildren) { + if(hasChildren) { final ITree flatMappedData = mapper.apply(data); final IList> mappedChildren = children @@ -212,14 +211,13 @@ public class Tree implements ITree { /* * Do a collapse of this tree. * - * @NOTE - * Why is this protected? I can't see any good reason someone'd - * want to override it. + * @NOTE Why is this protected? I can't see any good reason someone'd + * want to override it. */ protected NewType internalCollapse(final Function leafTransform, final Function> nodeCollapser) { - if (hasChildren) { + if(hasChildren) { final Function, NewType> nodeTransformer = nodeCollapser.apply(data); final IList collapsedChildren = children.map(child -> { @@ -236,7 +234,7 @@ public class Tree implements ITree { } protected void internalToString(final StringBuilder builder, final int indentLevel, final boolean initial) { - for (int i = 0; i < indentLevel; i++) { + for(int i = 0; i < indentLevel; i++) { builder.append(">\t"); } @@ -246,14 +244,14 @@ public class Tree implements ITree { builder.append(data == null ? "(null)" : data.toString()); builder.append("\n"); - if (hasChildren) { + if(hasChildren) { children.forEach(child -> { - if (child instanceof Tree) { + if(child instanceof Tree) { final Tree kid = (Tree) child; kid.internalToString(builder, indentLevel + 1, false); } else { - for (int i = 0; i < indentLevel + 1; i++) { + for(int i = 0; i < indentLevel + 1; i++) { builder.append(">\t"); } @@ -268,7 +266,7 @@ public class Tree implements ITree { @Override public ITree rebuildTree(final Function leafTransformer, final Function operatorTransformer) { - if (hasChildren) { + if(hasChildren) { final IList> mappedChildren = children.map(child -> { return child.rebuildTree(leafTransformer, operatorTransformer); }); @@ -283,7 +281,7 @@ public class Tree implements ITree { @Override public void selectiveTransform(final Predicate nodePicker, final UnaryOperator transformer) { - if (hasChildren) { + if(hasChildren) { children.forEach(child -> child.selectiveTransform(nodePicker, transformer)); } else { data = transformer.apply(data); @@ -296,11 +294,11 @@ public class Tree implements ITree { final UnaryOperator> transformer) { final TopDownTransformResult transformResult = transformPicker.apply(data); - switch (transformResult) { + switch(transformResult) { case PASSTHROUGH: ITree result = new Tree<>(data); - if (hasChildren) { + if(hasChildren) { children.forEach(child -> { final ITree kid = child.topDownTransform(transformPicker, transformer); @@ -319,7 +317,7 @@ public class Tree implements ITree { case PUSHDOWN: result = new Tree<>(data); - if (hasChildren) { + if(hasChildren) { children.forEach(child -> { final ITree kid = child.topDownTransform(transformPicker, transformer); @@ -351,7 +349,7 @@ public class Tree implements ITree { @Override public TransformedType transformChild(final int childNo, final Function, TransformedType> transformer) { - if (childNo < 0 || childNo > childCount - 1) { + if(childNo < 0 || childNo > childCount - 1) { final String msg = String.format("Child index #%d is invalid", childNo); throw new IllegalArgumentException(msg); @@ -394,21 +392,21 @@ public class Tree implements ITree { @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (!(obj instanceof Tree)) return false; + if(this == obj) return true; + if(obj == null) return false; + if(!(obj instanceof Tree)) return false; final Tree other = (Tree) obj; - if (data == null) { - if (other.data != null) return false; - } else if (!data.equals(other.data)) return false; + if(data == null) { + if(other.data != null) return false; + } else if(!data.equals(other.data)) return false; - if (childCount != other.childCount) return false; + if(childCount != other.childCount) return false; - if (children == null) { - if (other.children != null) return false; - } else if (!children.equals(other.children)) return false; + if(children == null) { + if(other.children != null) return false; + } else if(!children.equals(other.children)) return false; return true; } diff --git a/base/src/main/java/bjc/utils/data/ValueToggle.java b/base/src/main/java/bjc/utils/data/ValueToggle.java index 54c7a57..09f314c 100644 --- a/base/src/main/java/bjc/utils/data/ValueToggle.java +++ b/base/src/main/java/bjc/utils/data/ValueToggle.java @@ -6,13 +6,13 @@ package bjc.utils.data; * @author EVE * * @param - * The type of value to toggle between. + * The type of value to toggle between. */ public class ValueToggle implements Toggle { /* Our left value. */ - private final E lft; + private final E lft; /* Our right value. */ - private final E rght; + private final E rght; /* Our alignment. */ private final BooleanToggle alignment; @@ -22,10 +22,10 @@ public class ValueToggle implements Toggle { * All toggles start right-aligned. * * @param left - * The value when the toggle is left-aligned. + * The value when the toggle is left-aligned. * * @param right - * The value when the toggle is right-aligned. + * The value when the toggle is right-aligned. */ public ValueToggle(final E left, final E right) { lft = left; @@ -37,7 +37,7 @@ public class ValueToggle implements Toggle { @Override public E get() { - if (alignment.get()) { + if(alignment.get()) { return lft; } else { return rght; @@ -46,7 +46,7 @@ public class ValueToggle implements Toggle { @Override public E peek() { - if (alignment.peek()) { + if(alignment.peek()) { return lft; } else { return rght; diff --git a/base/src/main/java/bjc/utils/data/internals/BoundLazy.java b/base/src/main/java/bjc/utils/data/internals/BoundLazy.java index a1c2ea0..f4e8f7e 100644 --- a/base/src/main/java/bjc/utils/data/internals/BoundLazy.java +++ b/base/src/main/java/bjc/utils/data/internals/BoundLazy.java @@ -32,13 +32,13 @@ public class BoundLazy implements IHolder> actions = new FunctionalList<>(); /** - * Create a new bound lazy value. + * 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) { @@ -48,7 +48,7 @@ public class BoundLazy implements IHolder IHolder bind(final Function> bindr) { - if (bindr == null) throw new NullPointerException("Binder must not be null"); + if(bindr == null) throw new NullPointerException("Binder must not be null"); /* Prepare a list of pending actions. */ final IList> pendingActions = new FunctionalList<>(); @@ -59,7 +59,7 @@ 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); } @@ -75,7 +75,7 @@ public class BoundLazy implements IHolder Function> lift( final Function func) { - if (func == null) throw new NullPointerException("Function to lift must not be null"); + if(func == null) throw new NullPointerException("Function to lift must not be null"); return (val) -> { return new Lazy<>(func.apply(val)); @@ -84,7 +84,7 @@ public class BoundLazy implements IHolder IHolder map(final Function mapper) { - if (mapper == null) throw new NullPointerException("Mapper must not be null"); + if(mapper == null) throw new NullPointerException("Mapper must not be null"); /* Prepare a list of pending actions. */ final IList> pendingActions = new FunctionalList<>(); @@ -95,7 +95,7 @@ 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); } @@ -110,14 +110,14 @@ public class BoundLazy implements IHolder transform(final UnaryOperator transformer) { - if (transformer == null) throw new NullPointerException("Transformer must not be null"); + if(transformer == null) throw new NullPointerException("Transformer must not be null"); actions.add(transformer); @@ -126,9 +126,9 @@ public class BoundLazy implements IHolder UnwrappedType unwrap(final Function unwrapper) { - if (unwrapper == null) throw new NullPointerException("Unwrapper must not be null"); + if(unwrapper == null) throw new NullPointerException("Unwrapper must not be null"); - if (!holderBound) { + if(!holderBound) { boundHolder = oldSupplier.get().unwrap(binder::apply); } diff --git a/base/src/main/java/bjc/utils/data/internals/BoundLazyPair.java b/base/src/main/java/bjc/utils/data/internals/BoundLazyPair.java index 401f5d5..2ef0e4c 100644 --- a/base/src/main/java/bjc/utils/data/internals/BoundLazyPair.java +++ b/base/src/main/java/bjc/utils/data/internals/BoundLazyPair.java @@ -34,13 +34,14 @@ 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, final BiFunction> bindr) { @@ -52,13 +53,13 @@ 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 IHolder newPairMade = new Identity<>(pairBound); final Supplier leftSupp = () -> { - if (!newPairMade.getValue()) { + if(!newPairMade.getValue()) { /* * If the pair hasn't been bound before, bind * it. @@ -72,7 +73,7 @@ public class BoundLazyPair implements IPai }; final Supplier rightSupp = () -> { - if (!newPairMade.getValue()) { + if(!newPairMade.getValue()) { /* * If the pair hasn't been bound before, bind * it. @@ -91,12 +92,12 @@ public class BoundLazyPair implements IPai @Override public IPair bindLeft( final Function> leftBinder) { - if (leftBinder == null) throw new NullPointerException("Left binder must not be null"); + 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. @@ -113,12 +114,12 @@ public class BoundLazyPair implements IPai @Override public IPair bindRight( final Function> rightBinder) { - if (rightBinder == null) throw new NullPointerException("Right binder must not be null"); + 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. @@ -137,17 +138,17 @@ public class BoundLazyPair implements IPai final IPair otherPair, final BiFunction leftCombiner, final BiFunction rightCombiner) { - if (otherPair == null) { + 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); + CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft); CombinedRight cRight = rightCombiner.apply(rightVal, otherRight); return new LazyPair<>(cLeft, cRight); @@ -157,10 +158,10 @@ public class BoundLazyPair implements IPai @Override public IPair mapLeft(final Function mapper) { - if (mapper == null) throw new NullPointerException("Mapper must not be null"); + if(mapper == null) throw new NullPointerException("Mapper must not be null"); final Supplier leftSupp = () -> { - if (!pairBound) { + if(!pairBound) { final NewLeft leftVal = binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft(); return mapper.apply(leftVal); @@ -170,7 +171,7 @@ 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,16 +181,16 @@ public class BoundLazyPair implements IPai @Override public IPair mapRight(final Function mapper) { - if (mapper == null) throw new NullPointerException("Mapper must not be null"); + 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) { + if(!pairBound) { final NewRight rightVal = binder.apply(leftSupplier.get(), rightSupplier.get()) .getRight(); @@ -204,9 +205,9 @@ public class BoundLazyPair implements IPai @Override public MergedType merge(final BiFunction merger) { - if (merger == null) throw new NullPointerException("Merger must not be null"); + if(merger == null) throw new NullPointerException("Merger must not be null"); - if (!pairBound) { + if(!pairBound) { /* * If the pair isn't bound yet, bind it. */ @@ -220,7 +221,7 @@ 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/base/src/main/java/bjc/utils/data/internals/BoundListHolder.java b/base/src/main/java/bjc/utils/data/internals/BoundListHolder.java index 31178da..613f8e9 100644 --- a/base/src/main/java/bjc/utils/data/internals/BoundListHolder.java +++ b/base/src/main/java/bjc/utils/data/internals/BoundListHolder.java @@ -21,7 +21,7 @@ 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; @@ -29,7 +29,7 @@ public class BoundListHolder implements IHolder { @Override public IHolder bind(final Function> binder) { - if (binder == null) throw new NullPointerException("Binder must not be null"); + if(binder == null) throw new NullPointerException("Binder must not be null"); final IList> boundHolders = heldHolders.map((containedHolder) -> { return containedHolder.bind(binder); @@ -40,7 +40,7 @@ public class BoundListHolder implements IHolder { @Override public Function> lift(final Function func) { - if (func == null) throw new NullPointerException("Function to lift must not be null"); + if(func == null) throw new NullPointerException("Function to lift must not be null"); return (val) -> { return new ListHolder<>(func.apply(val)); @@ -49,7 +49,7 @@ public class BoundListHolder implements IHolder { @Override public IHolder map(final Function mapper) { - if (mapper == null) throw new NullPointerException("Mapper must not be null"); + if(mapper == null) throw new NullPointerException("Mapper must not be null"); final IList> mappedHolders = heldHolders.map((containedHolder) -> { return containedHolder.map(mapper); @@ -60,7 +60,7 @@ public class BoundListHolder implements IHolder { @Override public IHolder transform(final UnaryOperator transformer) { - if (transformer == null) throw new NullPointerException("Transformer must not be null"); + if(transformer == null) throw new NullPointerException("Transformer must not be null"); heldHolders.forEach((containedHolder) -> { containedHolder.transform(transformer); @@ -71,11 +71,10 @@ public class BoundListHolder implements IHolder { @Override public UnwrappedType unwrap(final Function unwrapper) { - if (unwrapper == null) throw new NullPointerException("Unwrapper must not be null"); + if(unwrapper == null) throw new NullPointerException("Unwrapper must not be null"); /* - * @NOTE - * Is there another way we could want to do this? + * @NOTE Is there another way we could want to do this? */ return heldHolders.randItem().unwrap(unwrapper); } diff --git a/base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java b/base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java index 5467255..4803bc2 100644 --- a/base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java +++ b/base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java @@ -31,18 +31,18 @@ public class HalfBoundLazyPair implements IPair> binder; /* The new bound pair. */ - private IPair boundPair; + private IPair boundPair; /* Has the pair been bound yet or not? */ - private boolean pairBound; + private boolean pairBound; /** * Create a new half-bound lazy pair. * * @param oldSupp - * The supplier of the old value. + * The supplier of the old value. * * @param bindr - * The function to use to create the pair from the old value. + * The function to use to create the pair from the old value. */ public HalfBoundLazyPair(final Supplier oldSupp, final Function> bindr) { @@ -57,7 +57,7 @@ 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); @@ -67,7 +67,7 @@ public class HalfBoundLazyPair implements IPair 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); @@ -85,7 +85,7 @@ public class HalfBoundLazyPair implements IPair leftSupp = () -> { IPair newPair = boundPair; - if (!pairBound) { + if(!pairBound) { newPair = binder.apply(oldSupplier.get()); } @@ -101,7 +101,7 @@ public class HalfBoundLazyPair implements IPair rightSupp = () -> { IPair newPair = boundPair; - if (!pairBound) { + if(!pairBound) { newPair = binder.apply(oldSupplier.get()); } @@ -118,7 +118,7 @@ public class HalfBoundLazyPair implements IPair rightCombiner) { return otherPair.bind((otherLeft, otherRight) -> { return bind((leftVal, rightVal) -> { - CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft); + CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft); CombinedRight cRight = rightCombiner.apply(rightVal, otherRight); return new LazyPair<>(cLeft, cRight); @@ -129,7 +129,7 @@ public class HalfBoundLazyPair implements IPair 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 +137,7 @@ public class HalfBoundLazyPair implements IPair rightSupp = () -> { - if (pairBound) return boundPair.getRight(); + if(pairBound) return boundPair.getRight(); return binder.apply(oldSupplier.get()).getRight(); }; @@ -148,13 +148,13 @@ public class HalfBoundLazyPair implements IPair 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(); @@ -166,7 +166,7 @@ public class HalfBoundLazyPair implements IPair MergedType merge(final BiFunction merger) { - if (!pairBound) { + if(!pairBound) { boundPair = binder.apply(oldSupplier.get()); pairBound = true; diff --git a/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java b/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java index a5c8130..57f9302 100644 --- a/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java +++ b/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java @@ -19,13 +19,13 @@ 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. * diff --git a/base/src/main/java/bjc/utils/data/internals/WrappedOption.java b/base/src/main/java/bjc/utils/data/internals/WrappedOption.java index 872295f..6260ce4 100644 --- a/base/src/main/java/bjc/utils/data/internals/WrappedOption.java +++ b/base/src/main/java/bjc/utils/data/internals/WrappedOption.java @@ -19,7 +19,7 @@ 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); @@ -38,7 +38,7 @@ public class WrappedOption implements IHolder { 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); }); @@ -58,7 +58,7 @@ public class WrappedOption implements IHolder { 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,7 +71,7 @@ public class WrappedOption implements IHolder { 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,7 +84,7 @@ public class WrappedOption implements IHolder { 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