From d2af58b0f68ebfbba2be7e7679efec6c8c0af12f Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 9 Feb 2017 11:50:31 -0500 Subject: Update --- .../java/bjc/utils/funcutils/CollectorUtils.java | 19 ++- .../bjc/utils/funcutils/CompoundCollector.java | 73 +++++------ .../main/java/bjc/utils/funcutils/EnumUtils.java | 12 +- .../main/java/bjc/utils/funcutils/FileUtils.java | 11 +- .../main/java/bjc/utils/funcutils/FuncUtils.java | 3 +- .../bjc/utils/funcutils/FunctionalFileVisitor.java | 22 ++-- .../bjc/utils/funcutils/GroupPartIteration.java | 27 ++-- .../main/java/bjc/utils/funcutils/ListUtils.java | 139 ++++++++++----------- .../main/java/bjc/utils/funcutils/NumberUtils.java | 11 +- .../main/java/bjc/utils/funcutils/StringUtils.java | 10 +- .../java/bjc/utils/funcutils/TokenDeaffixer.java | 14 +-- 11 files changed, 157 insertions(+), 184 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 0a1efd5..eb3695e 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/CollectorUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/CollectorUtils.java @@ -25,20 +25,17 @@ public class CollectorUtils { * The final type of the first collector * @param * The final type of the second collector - * @param firstCollector + * @param first * The first collector to use - * @param secondCollector + * @param second * The second collector to use * @return A collector that functions as mentioned above */ - public static Collector>, - IPair> compoundCollect( - Collector firstCollector, - Collector secondCollector) { - return new CompoundCollector<>(firstCollector, secondCollector); + public static + Collector>, IPair> + compoundCollect( + Collector first, + Collector second) { + return new CompoundCollector<>(first, second); } } 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 257f005..de5fe85 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/CompoundCollector.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/CompoundCollector.java @@ -12,77 +12,66 @@ import bjc.utils.data.IPair; import bjc.utils.data.Identity; import bjc.utils.data.Pair; -final class CompoundCollector implements - Collector>, - IPair> { - private Set< - java.util.stream.Collector.Characteristics> characteristicSet; +final class CompoundCollector + implements Collector>, IPair> { - private Collector firstCollector; - private Collector secondCollector; + private Set characteristicSet; + + private Collector first; + private Collector second; public CompoundCollector( - Collector firstCollector, - Collector secondCollector) { - this.firstCollector = firstCollector; - this.secondCollector = secondCollector; + Collector first, + Collector second) { + this.first = first; + this.second = second; - characteristicSet = firstCollector.characteristics(); - characteristicSet.addAll(secondCollector.characteristics()); + characteristicSet = first.characteristics(); + characteristicSet.addAll(second.characteristics()); } @Override - public BiConsumer>, - InitialType> accumulator() { - BiConsumer firstAccumulator = firstCollector - .accumulator(); - BiConsumer secondAccumulator = secondCollector - .accumulator(); + public BiConsumer>, InitialType> accumulator() { + BiConsumer firstAccumulator = first.accumulator(); + BiConsumer secondAccumulator = second.accumulator(); return (state, value) -> { state.doWith((statePair) -> { - statePair.doWith((leftState, rightState) -> { - firstAccumulator.accept(leftState, value); - secondAccumulator.accept(rightState, value); + statePair.doWith((left, right) -> { + firstAccumulator.accept(left, value); + secondAccumulator.accept(right, value); }); }); }; } @Override - public Set< - java.util.stream.Collector.Characteristics> characteristics() { + public Set characteristics() { return characteristicSet; } @Override public BinaryOperator>> combiner() { - BinaryOperator firstCombiner = firstCollector.combiner(); - BinaryOperator< - AuxType2> secondCombiner = secondCollector.combiner(); + BinaryOperator firstCombiner = first.combiner(); + BinaryOperator secondCombiner = second.combiner(); return (leftState, rightState) -> { return leftState.unwrap((leftPair) -> { return rightState.transform((rightPair) -> { - return leftPair.combine(rightPair, firstCombiner, - secondCombiner); + return leftPair.combine(rightPair, firstCombiner, secondCombiner); }); }); }; } @Override - public Function>, - IPair> finisher() { + public Function>, IPair> finisher() { return (state) -> { return state.unwrap((pair) -> { - return pair.bind((leftVal, rightVal) -> { + return pair.bind((left, right) -> { return new Pair<>( - firstCollector.finisher().apply(leftVal), - secondCollector.finisher().apply(rightVal)); + first.finisher().apply(left), + second.finisher().apply(right)); }); }); }; @@ -90,8 +79,10 @@ final class CompoundCollector>> supplier() { - return () -> new Identity<>( - new Pair<>(firstCollector.supplier().get(), - secondCollector.supplier().get())); + return () -> { + return new Identity<>(new Pair<>( + first.supplier().get(), + second.supplier().get())); + }; } -} \ No newline at end of file +} diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/EnumUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/EnumUtils.java index 61b13ea..9be6080 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/EnumUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/EnumUtils.java @@ -18,7 +18,7 @@ public class EnumUtils { * * @param * The type of the enum - * @param enumClass + * @param clasz * The enum class * @param nValues * The number of values to execute the action on @@ -27,9 +27,9 @@ public class EnumUtils { * @param rnd * The source of randomness to use */ - public static > void doForValues(Class enumClass, + public static > void doForValues(Class clasz, int nValues, Consumer action, Random rnd) { - E[] enumValues = enumClass.getEnumConstants(); + E[] enumValues = clasz.getEnumConstants(); IList valueList = new FunctionalList<>(enumValues); @@ -49,15 +49,15 @@ public class EnumUtils { * * @param * The type of the enum - * @param enumClass + * @param clasz * The class of the enum * @param rnd * The random source to use * @return A random value from the specified enum */ - public static > E getRandomValue(Class enumClass, + public static > E getRandomValue(Class clasz, Random rnd) { - E[] enumValues = enumClass.getEnumConstants(); + E[] enumValues = clasz.getEnumConstants(); return new FunctionalList<>(enumValues).randItem(rnd::nextInt); } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/FileUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/FileUtils.java index ea5c72e..6fc09ff 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/FileUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/FileUtils.java @@ -19,10 +19,10 @@ public class FileUtils { * * @param root * The directory to start the traversal at - * @param traversalPredicate + * @param predicate * The predicate to determine whether or not to traverse a * directory - * @param traversalAction + * @param action * The action to invoke upon each file in the directory. * Returning true means to continue the traversal, returning * false stops it @@ -33,10 +33,9 @@ public class FileUtils { * this with all the buttons and knobs from walkFileTree */ public static void traverseDirectory(Path root, - BiPredicate traversalPredicate, - BiPredicate traversalAction) + BiPredicate predicate, + BiPredicate action) throws IOException { - Files.walkFileTree(root, new FunctionalFileVisitor( - traversalPredicate, traversalAction)); + Files.walkFileTree(root, new FunctionalFileVisitor(predicate, action)); } } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/FuncUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/FuncUtils.java index 43603d6..679af52 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/FuncUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/FuncUtils.java @@ -26,8 +26,7 @@ public class FuncUtils { * @return The function transformed into a unary function returning a * function */ - public static Function> curry2( - BiFunction func) { + public static Function> curry2(BiFunction func) { return (arg1) -> (arg2) -> { return func.apply(arg1, arg2); }; diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/FunctionalFileVisitor.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/FunctionalFileVisitor.java index 2308d7c..cd833d9 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/FunctionalFileVisitor.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/FunctionalFileVisitor.java @@ -8,20 +8,20 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.function.BiPredicate; final class FunctionalFileVisitor extends SimpleFileVisitor { - private BiPredicate traversalPredicate; - private BiPredicate traversalAction; + private BiPredicate predicate; + private BiPredicate action; public FunctionalFileVisitor( - BiPredicate traversalPredicate, - BiPredicate traversalAction) { - this.traversalPredicate = traversalPredicate; - this.traversalAction = traversalAction; + BiPredicate predicate, + BiPredicate action) { + this.predicate = predicate; + this.action = action; } @Override - public FileVisitResult preVisitDirectory(Path dir, - BasicFileAttributes attrs) throws IOException { - if (traversalPredicate.test(dir, attrs)) { + public FileVisitResult preVisitDirectory( + Path dir, BasicFileAttributes attrs) throws IOException { + if (predicate.test(dir, attrs)) { return FileVisitResult.CONTINUE; } @@ -31,10 +31,10 @@ final class FunctionalFileVisitor extends SimpleFileVisitor { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - if (traversalAction.test(file, attrs)) { + if (action.test(file, attrs)) { return FileVisitResult.CONTINUE; } return FileVisitResult.TERMINATE; } -} \ No newline at end of file +} diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/GroupPartIteration.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/GroupPartIteration.java index 81781f6..229d271 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/GroupPartIteration.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/GroupPartIteration.java @@ -17,10 +17,13 @@ import bjc.utils.funcdata.IList; */ final class GroupPartIteration implements Consumer { private IList> returnedList; + private IHolder> currentPartition; private IList rejectedItems; + private IHolder numberInCurrentPartition; private int numberPerPartition; + private Function elementCounter; public GroupPartIteration(IList> returned, @@ -37,26 +40,24 @@ final class GroupPartIteration implements Consumer { @Override public void accept(E value) { - if (numberInCurrentPartition - .unwrap((number) -> number >= numberPerPartition)) { - returnedList.add( - currentPartition.unwrap((partition) -> partition)); + if (numberInCurrentPartition.unwrap((number) -> number >= numberPerPartition)) { + returnedList.add(currentPartition.unwrap((partition) -> partition)); - currentPartition - .transform((partition) -> new FunctionalList<>()); + currentPartition.transform((partition) -> new FunctionalList<>()); numberInCurrentPartition.transform((number) -> 0); } else { int currentElementCount = elementCounter.apply(value); - if (numberInCurrentPartition.unwrap((number) -> (number - + currentElementCount) >= numberPerPartition)) { + boolean shouldReject = numberInCurrentPartition.unwrap((number) -> { + return (number + currentElementCount) >= numberPerPartition; + }); + + if (shouldReject) { rejectedItems.add(value); } else { - currentPartition - .unwrap((partition) -> partition.add(value)); - numberInCurrentPartition.transform( - (number) -> number + currentElementCount); + currentPartition.unwrap((partition) -> partition.add(value)); + numberInCurrentPartition.transform((number) -> number + currentElementCount); } } } -} \ No newline at end of file +} 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 94571f5..4b17b41 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/ListUtils.java @@ -47,8 +47,7 @@ public class ListUtils { * The seperator to use for seperating tokens * @return The collapsed string of tokens */ - public static String collapseTokens(IList input, - String seperator) { + public static String collapseTokens(IList input, String seperator) { if (input == null) { throw new NullPointerException("Input must not be null"); } else if (seperator == null) { @@ -60,12 +59,13 @@ public class ListUtils { } else if (input.getSize() == 1) { return input.first(); } else { - return input.reduceAux("", (currentString, state) -> { - return state + currentString + seperator; - }, (strang) -> { - return strang.substring(0, - strang.length() - seperator.length()); - }); + return input.reduceAux("", + (currentString, state) -> { + return state + currentString + seperator; + }, + (strang) -> { + return strang.substring(0, strang.length() - seperator.length()); + }); } } @@ -84,21 +84,20 @@ public class ListUtils { 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"); + throw new NullPointerException("Set of operators must not be null"); } - IHolder> returnedList = new Identity<>(input); + IHolder> returned = new Identity<>(input); operators.forEach((operator) -> { - returnedList.transform((oldReturn) -> { - return oldReturn.flatMap((token) -> { + returned.transform((old) -> { + return old.flatMap((token) -> { return operator.merge(new TokenDeaffixer(token)); }); }); }); - return returnedList.unwrap((list) -> list); + return returned.unwrap((list) -> list); } /** @@ -108,7 +107,7 @@ public class ListUtils { * The type of items to select * @param list * The list to select from - * @param numberOfItems + * @param number * The number of items to selet * @param rng * A function that creates a random number from 0 to the @@ -117,26 +116,25 @@ public class ListUtils { * selected from the specified list without replacement */ - public static IList drawWithoutReplacement(IList list, - int numberOfItems, Function rng) { - IList selectedItems = new FunctionalList<>( - new ArrayList<>(numberOfItems)); + public static IList drawWithoutReplacement( + IList list, int number, Function rng) { + IList selected = new FunctionalList<>(new ArrayList<>(number)); - int totalItems = list.getSize(); + int total = list.getSize(); list.forEachIndexed((index, element) -> { - int winningChance = numberOfItems - selectedItems.getSize(); + int winningChance = number - selected.getSize(); // n - m - int totalChance = totalItems - (index - 1); + int totalChance = total - (index - 1); // N - t // Probability of selecting the t+1'th element if (NumberUtils.isProbable(winningChance, totalChance, rng)) { - selectedItems.add(element); + selected.add(element); } }); - return selectedItems; + return selected; } /** @@ -146,7 +144,7 @@ public class ListUtils { * The type of items to select * @param list * The list to select from - * @param numberOfItems + * @param number * The number of items to selet * @param rng * A function that creates a random number from 0 to the @@ -155,15 +153,14 @@ public class ListUtils { * selected from the specified list */ public static IList drawWithReplacement(IList list, - int numberOfItems, Function rng) { - IList selectedItems = new FunctionalList<>( - new ArrayList<>(numberOfItems)); + int number, Function rng) { + IList selected = new FunctionalList<>(new ArrayList<>(number)); - for (int i = 0; i < numberOfItems; i++) { - selectedItems.add(list.randItem(rng)); + for (int i = 0; i < number; i++) { + selected.add(list.randItem(rng)); } - return selectedItems; + return selected; } /** @@ -175,23 +172,22 @@ public class ListUtils { * * @param input * The list to partition - * @param elementCounter + * @param counter * The function to determine the count for each element for - * @param numberPerPartition + * @param partitionSize * The number of elements to put in each partition * * @return A list partitioned according to the above rules */ - public static IList> groupPartition(IList input, - Function elementCounter, int numberPerPartition) { + public static IList> groupPartition( + IList input, Function counter, int partitionSize) { if (input == null) { throw new NullPointerException("Input list must not be null"); - } else if (elementCounter == null) { + } else if (counter == null) { throw new NullPointerException("Counter must not be null"); - } else if (numberPerPartition < 1 - || numberPerPartition > input.getSize()) { + } else if (partitionSize < 1 || partitionSize > input.getSize()) { throw new IllegalArgumentException( - "" + numberPerPartition + " is not a valid" + "" + partitionSize + " is not a valid" + " partition size. Must be between 1 and " + input.getSize()); } @@ -199,36 +195,36 @@ public class ListUtils { /* * List that holds our results */ - IList> returnedList = new FunctionalList<>(); + IList> returned = new FunctionalList<>(); /* * List that holds current partition */ - IHolder> currentPartition = new Identity<>( - new FunctionalList<>()); + IHolder> current = new Identity<>(new FunctionalList<>()); + /* * List that holds elements rejected during current pass */ - IList rejectedElements = new FunctionalList<>(); + IList rejected = new FunctionalList<>(); /* * The effective number of elements in the current partitition */ - IHolder numberInCurrentPartition = new Identity<>(0); + IHolder currentSize = new Identity<>(0); /* * Run up to a certain number of passes */ for (int numberOfIterations = 0; numberOfIterations < MAX_NTRIESPART - && !rejectedElements.isEmpty(); numberOfIterations++) { - input.forEach(new GroupPartIteration<>(returnedList, - currentPartition, rejectedElements, - numberInCurrentPartition, numberPerPartition, - elementCounter)); + && !rejected.isEmpty(); numberOfIterations++) { + input.forEach(new GroupPartIteration<>(returned, + current, rejected, + currentSize, partitionSize, + counter)); - if (rejectedElements.isEmpty()) { + if (rejected.isEmpty()) { // Nothing was rejected, so we're done - return returnedList; + return returned; } } @@ -237,11 +233,11 @@ public class ListUtils { + " iterations of partitioning) detected unpartitionable list " + input.toString() + "\nThe following elements were not partitioned: " - + rejectedElements.toString() + + rejected.toString() + "\nCurrent group in formation: " - + currentPartition.unwrap((vl) -> vl.toString()) + + current.unwrap((vl) -> vl.toString()) + "\nPreviously formed groups: " - + returnedList.toString()); + + returned.toString()); } /** @@ -255,13 +251,13 @@ public class ListUtils { */ @SafeVarargs public static IList mergeLists(IList... lists) { - IList returnedList = new FunctionalList<>(); + IList returned = new FunctionalList<>(); for (IList list : lists) { - list.forEach(returnedList::add); + list.forEach(returned::add); } - return returnedList; + return returned; } /** @@ -275,7 +271,7 @@ public class ListUtils { * The function to count elements with * @param size * The desired size of the list - * @param padSource + * @param padder * The function to get elements to pad with * @return The list, padded to the desired size * @throws IllegalArgumentException @@ -283,26 +279,26 @@ public class ListUtils { */ public static IList padList(IList list, Function counter, int size, - Supplier padSource) { - IHolder countHolder = new Identity<>(0); + Supplier padder) { + IHolder count = new Identity<>(0); - IList ret = list.map((elm) -> { - countHolder.map((val) -> val + counter.apply(elm)); + IList returned = list.map((elm) -> { + count.map((val) -> val + counter.apply(elm)); return elm; }); - if (countHolder.unwrap((val) -> val % size != 0)) { + if (count.unwrap((val) -> val % size != 0)) { // We need to pad - int needed = countHolder.unwrap((val) -> val % size); + int needed = count.unwrap((val) -> val % size); int threshold = 0; while (needed > 0 && threshold <= MAX_NTRIESPART) { - E val = padSource.get(); + E val = padder.get(); int count = counter.apply(val); if (count <= needed) { - ret.add(val); + returned.add(val); threshold = 0; @@ -319,7 +315,7 @@ public class ListUtils { } } - return ret; + return returned; } /** @@ -341,20 +337,19 @@ public class ListUtils { 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"); + throw new NullPointerException("Set of operators must not be null"); } - IHolder> returnedList = new Identity<>(input); + IHolder> returned = new Identity<>(input); operators.forEach((operator) -> { - returnedList.transform((oldReturn) -> { + returned.transform((oldReturn) -> { return oldReturn.flatMap((token) -> { return operator.merge(new TokenSplitter(token)); }); }); }); - return returnedList.getValue(); + return returned.getValue(); } } 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 419c787..24c2014 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,7 @@ 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; } @@ -38,16 +37,16 @@ public class NumberUtils { /** * Evaluates a linear probability distribution * - * @param topExp + * @param winning * The number of winning possibilities - * @param bottomExp + * @param total * The number of total possibilities * @param rng * The function to use to generate a random possibility * @return Whether or not a random possibility was a winning one */ - public static boolean isProbable(int topExp, int bottomExp, + public static boolean isProbable(int winning, int total, Function rng) { - return rng.apply(bottomExp) < topExp; + return rng.apply(total) < winning; } } 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 7573bfb..6770df2 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java @@ -9,7 +9,6 @@ import java.util.Deque; * */ public class StringUtils { - /** * Checks if the given expression contains the specified operator in a * situation that indicates its use as an infix operator. @@ -21,12 +20,10 @@ public class StringUtils { * @return Whether or not the given expression contains the specified * operator as a infix operator */ - public static boolean containsInfixOperator(String expression, - String operator) { + public static boolean containsInfixOperator(String expression, String operator) { // Bit annoying to have to use a full class name, but what are you // going to do? - return org.apache.commons.lang3.StringUtils - .countMatches(expression, operator) == 1 + return org.apache.commons.lang3.StringUtils.countMatches(expression, operator) == 1 && !expression.equalsIgnoreCase(operator) && !expression.startsWith(operator); } @@ -85,8 +82,7 @@ public class StringUtils { * @return A string version of the deque, with allowance for an empty * deque */ - public static < - ContainedType> String printDeque(Deque queue) { + public static String printDeque(Deque queue) { return queue.isEmpty() ? "(none)" : queue.toString(); } } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java index 709538b..79f6e3b 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/TokenDeaffixer.java @@ -16,23 +16,19 @@ final class TokenDeaffixer @Override public IList apply(String operatorName, String operatorRegex) { if (operatorName == null) { - throw new NullPointerException( - "Operator name must not be null"); + throw new NullPointerException("Operator name must not be null"); } else if (operatorRegex == null) { - throw new NullPointerException( - "Operator regex must not be null"); + throw new NullPointerException("Operator regex must not be null"); } if (StringUtils.containsOnly(token, operatorRegex)) { return new FunctionalList<>(token); } else if (token.startsWith(operatorName)) { - return new FunctionalList<>(operatorName, - token.split(operatorRegex)[1]); + return new FunctionalList<>(operatorName, token.split(operatorRegex)[1]); } else if (token.endsWith(operatorName)) { - return new FunctionalList<>(token.split(operatorRegex)[0], - operatorName); + return new FunctionalList<>(token.split(operatorRegex)[0], operatorName); } else { return new FunctionalList<>(token); } } -} \ No newline at end of file +} -- cgit v1.2.3