From f7a10e0e57d6f0ea83643c3d5763ff405af73337 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Wed, 28 Sep 2016 13:44:04 -0400 Subject: Formatting pass --- .../java/bjc/utils/funcutils/CollectorUtils.java | 11 ++- .../bjc/utils/funcutils/CompoundCollector.java | 31 +++++---- .../main/java/bjc/utils/funcutils/ListUtils.java | 78 +++++++++++----------- .../main/java/bjc/utils/funcutils/NumberUtils.java | 4 +- .../main/java/bjc/utils/funcutils/StringUtils.java | 4 +- 5 files changed, 71 insertions(+), 57 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcutils') diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/CollectorUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/CollectorUtils.java index f7210b5..0a1efd5 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/CollectorUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/CollectorUtils.java @@ -31,9 +31,14 @@ public class CollectorUtils { * The second collector to use * @return A collector that functions as mentioned above */ - public static Collector>, IPair> compoundCollect( - Collector firstCollector, - Collector secondCollector) { + public static Collector>, + IPair> compoundCollect( + Collector firstCollector, + Collector secondCollector) { return new CompoundCollector<>(firstCollector, secondCollector); } } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/CompoundCollector.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/CompoundCollector.java index 60eb163..257f005 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/CompoundCollector.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/CompoundCollector.java @@ -12,13 +12,16 @@ import bjc.utils.data.IPair; import bjc.utils.data.Identity; import bjc.utils.data.Pair; -final class CompoundCollector - implements - Collector>, IPair> { - private Set characteristicSet; +final class CompoundCollector implements + Collector>, + IPair> { + private Set< + java.util.stream.Collector.Characteristics> characteristicSet; private Collector firstCollector; - private Collector secondCollector; + private Collector secondCollector; public CompoundCollector( Collector firstCollector, @@ -31,11 +34,13 @@ final class CompoundCollector>, InitialType> accumulator() { + public BiConsumer>, + InitialType> accumulator() { BiConsumer firstAccumulator = firstCollector .accumulator(); - BiConsumer secondAccumulator = secondCollector - .accumulator(); + BiConsumer secondAccumulator = secondCollector + .accumulator(); return (state, value) -> { state.doWith((statePair) -> { @@ -48,15 +53,16 @@ final class CompoundCollector characteristics() { + public Set< + java.util.stream.Collector.Characteristics> characteristics() { return characteristicSet; } @Override public BinaryOperator>> combiner() { BinaryOperator firstCombiner = firstCollector.combiner(); - BinaryOperator secondCombiner = secondCollector - .combiner(); + BinaryOperator< + AuxType2> secondCombiner = secondCollector.combiner(); return (leftState, rightState) -> { return leftState.unwrap((leftPair) -> { @@ -69,7 +75,8 @@ final class CompoundCollector>, IPair> finisher() { + public Function>, + IPair> finisher() { return (state) -> { return state.unwrap((pair) -> { return pair.bind((leftVal, rightVal) -> { diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java index d65603b..3b03406 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java @@ -216,8 +216,10 @@ public class ListUtils { /* * Run up to a certain number of passes */ - for (int numberOfIterations = 0; numberOfIterations < MAX_NTRIESPART - && !rejectedElements.isEmpty(); numberOfIterations++) { + for (int numberOfIterations = 0; + numberOfIterations < MAX_NTRIESPART + && !rejectedElements.isEmpty(); + numberOfIterations++) { input.forEach(new GroupPartIteration<>(returnedList, currentPartition, rejectedElements, numberInCurrentPartition, numberPerPartition, @@ -261,42 +263,6 @@ public class ListUtils { return returnedList; } - /** - * Split tokens in a list of tokens into multiple tokens. - * - * The intended use is for expression parsers so that you can enter - * something like 1+1 instead of 1 + 1. - * - * @param input - * The tokens to split - * @param operators - * Pairs of operators to split on and regexes that match - * those operators - * @return A list of tokens split on all the operators - * - */ - public static IList splitTokens(IList input, - Deque> operators) { - if (input == null) { - throw new NullPointerException("Input must not be null"); - } else if (operators == null) { - throw new NullPointerException( - "Set of operators must not be null"); - } - - IHolder> returnedList = new Identity<>(input); - - operators.forEach((operator) -> { - returnedList.transform((oldReturn) -> { - return oldReturn.flatMap((token) -> { - return operator.merge(new TokenSplitter(token)); - }); - }); - }); - - return returnedList.getValue(); - } - public static IList padList(IList list, Function counter, int size, Supplier padSource) { @@ -337,4 +303,40 @@ public class ListUtils { return ret; } + + /** + * Split tokens in a list of tokens into multiple tokens. + * + * The intended use is for expression parsers so that you can enter + * something like 1+1 instead of 1 + 1. + * + * @param input + * The tokens to split + * @param operators + * Pairs of operators to split on and regexes that match + * those operators + * @return A list of tokens split on all the operators + * + */ + public static IList splitTokens(IList input, + Deque> operators) { + if (input == null) { + throw new NullPointerException("Input must not be null"); + } else if (operators == null) { + throw new NullPointerException( + "Set of operators must not be null"); + } + + IHolder> returnedList = new Identity<>(input); + + operators.forEach((operator) -> { + returnedList.transform((oldReturn) -> { + return oldReturn.flatMap((token) -> { + return operator.merge(new TokenSplitter(token)); + }); + }); + }); + + return returnedList.getValue(); + } } \ No newline at end of file diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/NumberUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/NumberUtils.java index 1f8f61d..419c787 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/NumberUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/NumberUtils.java @@ -26,8 +26,8 @@ public class NumberUtils { } else { int result = 1; - for (int currentSub = 0; currentSub < power - + 1; currentSub++) { + for (int currentSub = 0; currentSub < power + 1; + currentSub++) { result *= value - currentSub; } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java index 6ddf420..7573bfb 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java @@ -85,8 +85,8 @@ public class StringUtils { * @return A string version of the deque, with allowance for an empty * deque */ - public static String printDeque( - Deque queue) { + public static < + ContainedType> String printDeque(Deque queue) { return queue.isEmpty() ? "(none)" : queue.toString(); } } -- cgit v1.2.3