diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-25 14:07:24 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-25 14:07:24 -0400 |
| commit | 674d9769821775484fe6913b93c650189fbedfed (patch) | |
| tree | eebef3fe254ee49a7f12f24ea68fab8570096219 /BJC-Utils2/src | |
| parent | 42a897dae1bfa58ab665f5012c2ac160316bcb75 (diff) | |
General cleanup
Diffstat (limited to 'BJC-Utils2/src')
9 files changed, 55 insertions, 50 deletions
diff --git a/BJC-Utils2/src/examples/java/bjc/utils/examples/parsing/TreeConstructTest.java b/BJC-Utils2/src/examples/java/bjc/utils/examples/parsing/TreeConstructTest.java index 27a2c3e..a78a3d5 100644 --- a/BJC-Utils2/src/examples/java/bjc/utils/examples/parsing/TreeConstructTest.java +++ b/BJC-Utils2/src/examples/java/bjc/utils/examples/parsing/TreeConstructTest.java @@ -50,7 +50,7 @@ public class TreeConstructTest { * @param args * Unused CLI args */ - @SuppressWarnings("resource") + @SuppressWarnings({ "resource", "deprecation" }) public static void main(String[] args) { Scanner inputSource = new Scanner(System.in); diff --git a/BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java b/BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java index 3b3a9a7..58efc80 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java @@ -7,8 +7,9 @@ package bjc.utils.esodata; * only affect elements at that cursor. The size of the array is theoretically * unbounded to the right, but in practice bounded by available memory. * - * @param T + * @param <T> * The element type of the tape. + * * @author bjculkin */ public interface Tape<T> { 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 51be875..a35253a 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/StringUtils.java @@ -24,8 +24,7 @@ public class StringUtils { public static boolean containsOnly(String input, String regex) { if (input == null) throw new NullPointerException("Input must not be null"); - else if (regex == null) - throw new NullPointerException("Regex must not be null"); + else if (regex == null) throw new NullPointerException("Regex must not be null"); /* * This regular expression is fairly simple. @@ -78,7 +77,7 @@ public class StringUtils { * @param comma * The string to use as a comma * - * @return + * @return The sequence as an English list. */ public static String toEnglishList(Object[] objects, String join, String comma) { if (objects == null) { @@ -141,7 +140,7 @@ public class StringUtils { * The string to use for separating the last element from * the rest. * - * @return + * @return The sequence as an English list. */ public static String toEnglishList(Object[] objects, String join) { return toEnglishList(objects, join, ","); @@ -155,7 +154,7 @@ public class StringUtils { * @param and * Whether to use 'and' or 'or'. * - * @return + * @return The sequence as an English list. */ public static String toEnglishList(Object[] objects, boolean and) { if (and) { diff --git a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java index 6179850..15d7753 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java @@ -242,19 +242,22 @@ public class WeightedGrammar<E> { } /** - * Generate a generic sentance from a initial rule. + * Generate a generic sentence from a initial rule. * * @param <T> * The type of the transformed output * - * @param initRule + * @param initRules * The initial rule to start with. + * * @param tokenTransformer * The function to transform grammar output into * something. + * * @param spacer * The spacer element to add in between output tokens. - * @return A randomly generated sentance from the specified initial + * + * @return A randomly generated sentence from the specified initial * rule. */ public <T> IList<T> generateGenericValues(E initRules, Function<E, T> tokenTransformer, T spacer) { diff --git a/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java b/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java index 003b996..d033f04 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java +++ b/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java @@ -72,12 +72,12 @@ public class Graph<T> { */ public void addEdge(T source, T target, int distance, boolean directed) { // Can't add edges with a null source or target - if(source == null) + if (source == null) throw new NullPointerException("The source vertex cannot be null"); - else if(target == null) throw new NullPointerException("The target vertex cannot be null"); + else if (target == null) throw new NullPointerException("The target vertex cannot be null"); // Initialize adjacency list for vertices if necessary - if(!backing.containsKey(source)) { + if (!backing.containsKey(source)) { backing.put(source, new FunctionalMap<T, Integer>()); } @@ -85,8 +85,8 @@ public class Graph<T> { backing.get(source).put(target, distance); // Handle possible directed edges - if(!directed) { - if(!backing.containsKey(target)) { + if (!directed) { + if (!backing.containsKey(target)) { backing.put(target, new FunctionalMap<T, Integer>()); } @@ -106,12 +106,12 @@ public class Graph<T> { * The action to execute for matching edges */ public void forAllEdgesMatchingAt(T source, BiPredicate<T, Integer> matcher, BiConsumer<T, Integer> action) { - if(matcher == null) + if (matcher == null) throw new NullPointerException("Matcher must not be null"); - else if(action == null) throw new NullPointerException("Action must not be null"); + else if (action == null) throw new NullPointerException("Action must not be null"); getEdges(source).forEach((target, weight) -> { - if(matcher.test(target, weight)) { + if (matcher.test(target, weight)) { action.accept(target, weight); } }); @@ -126,9 +126,9 @@ public class Graph<T> { */ public IMap<T, Integer> getEdges(T source) { // Can't find edges for a null source - if(source == null) + if (source == null) throw new NullPointerException("The source cannot be null."); - else if(!backing.containsKey(source)) + else if (!backing.containsKey(source)) throw new IllegalArgumentException("Vertex " + source + " is not in graph"); return backing.get(source); @@ -168,7 +168,7 @@ public class Graph<T> { visited.add(source.getValue()); // Make sure we visit all the nodes - while(visited.size() != getVertexCount()) { + while (visited.size() != getVertexCount()) { // Grab all edges adjacent to the provided edge forAllEdgesMatchingAt(source.getValue(), (target, weight) -> { @@ -185,7 +185,7 @@ public class Graph<T> { // Only consider edges where we haven't visited the // target of // the edge - while(visited.contains(minimum.getValue())) { + while (visited.contains(minimum.getValue().getTarget())) { minimum.transform((edge) -> available.poll()); } @@ -230,15 +230,15 @@ public class Graph<T> { */ public void removeEdge(T source, T target) { // Can't remove things w/ null vertices - if(source == null) + if (source == null) throw new NullPointerException("The source vertex cannot be null"); - else if(target == null) throw new NullPointerException("The target vertex cannot be null"); + else if (target == null) throw new NullPointerException("The target vertex cannot be null"); // Can't remove if one vertice doesn't exists - if(!backing.containsKey(source)) + if (!backing.containsKey(source)) throw new NoSuchElementException("vertex " + source + " does not exist."); - if(!backing.containsKey(target)) + if (!backing.containsKey(target)) throw new NoSuchElementException("vertex " + target + " does not exist."); backing.get(source).remove(target); diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java index 2a0bdff..7fc3688 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java @@ -72,26 +72,26 @@ public class ShuntingYard<TokenType> { @Override public void accept(String token) { // Handle operators - if(operators.containsKey(token)) { + if (operators.containsKey(token)) { // Pop operators while there isn't a higher // precedence one - while(!stack.isEmpty() && isHigherPrec(token, stack.peek())) { + while (!stack.isEmpty() && isHigherPrec(token, stack.peek())) { output.add(transformer.apply(stack.pop())); } // Put this operator onto the stack stack.push(token); - } else if(StringUtils.containsOnly(token, "\\(")) { + } else if (StringUtils.containsOnly(token, "\\(")) { // Handle groups of parenthesis for multiple // nesting levels stack.push(token); - } else if(StringUtils.containsOnly(token, "\\)")) { + } else if (StringUtils.containsOnly(token, "\\)")) { // Handle groups of parenthesis for multiple // nesting levels String swappedToken = token.replace(')', '('); // Remove tokens up to a matching parenthesis - while(!stack.peek().equals(swappedToken)) { + while (!stack.peek().equals(swappedToken)) { output.add(transformer.apply(stack.pop())); } @@ -119,7 +119,7 @@ public class ShuntingYard<TokenType> { operators = new FunctionalMap<>(); // Add basic operators if we're configured to do so - if(configureBasics) { + if (configureBasics) { operators.put("+", Operator.ADD); operators.put("-", Operator.SUBTRACT); operators.put("*", Operator.MULTIPLY); @@ -130,13 +130,15 @@ public class ShuntingYard<TokenType> { /** * Add an operator to the list of shuntable operators * - * @param operatorToken + * @param operator * The token representing the operator * @param precedence * The precedence of the operator to add */ public void addOp(String operator, int precedence) { - // Create the precedence marker + /* + * Create the precedence marker + */ IPrecedent prec = IPrecedent.newSimplePrecedent(precedence); this.addOp(operator, prec); @@ -145,18 +147,23 @@ public class ShuntingYard<TokenType> { /** * Add an operator to the list of shuntable operators * - * @param operatorToken + * @param operator * The token representing the operator + * * @param precedence * The precedence of the operator */ public void addOp(String operator, IPrecedent precedence) { - // Complain about trying to add an incorrect operator - if(operator == null) + /* + * Complain about trying to add an incorrect operator + */ + if (operator == null) throw new NullPointerException("Operator must not be null"); - else if(precedence == null) throw new NullPointerException("Precedence must not be null"); + else if (precedence == null) throw new NullPointerException("Precedence must not be null"); - // Add the operator to the ones we handle + /* + * Add the operator to the ones we handle + */ operators.put(operator, precedence); } @@ -165,7 +172,7 @@ public class ShuntingYard<TokenType> { boolean exists = operators.containsKey(right); // If it doesn't, the left is higher precedence. - if(!exists) return false; + if (!exists) return false; // Get the precedence of operators int rightPrecedence = operators.get(right).getPrecedence(); @@ -186,9 +193,9 @@ public class ShuntingYard<TokenType> { */ public IList<TokenType> postfix(IList<String> input, Function<String, TokenType> transformer) { // Check our input - if(input == null) + if (input == null) throw new NullPointerException("Input must not be null"); - else if(transformer == null) throw new NullPointerException("Transformer must not be null"); + else if (transformer == null) throw new NullPointerException("Transformer must not be null"); // Here's what we're handing back IList<TokenType> output = new FunctionalList<>(); @@ -210,13 +217,13 @@ public class ShuntingYard<TokenType> { /** * Remove an operator from the list of shuntable operators * - * @param token + * @param operator * The token representing the operator. If null, remove * all operators */ public void removeOp(String operator) { // Check if we want to remove all operators - if(operator == null) { + if (operator == null) { operators = new FunctionalMap<>(); } else { operators.remove(operator); diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/delims/DelimiterGroup.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/delims/DelimiterGroup.java index 652b8f6..db6ae8c 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/delims/DelimiterGroup.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/delims/DelimiterGroup.java @@ -431,9 +431,6 @@ public class DelimiterGroup<T> { * * @param priority * The priority of this sub-group. - * - * @param contained - * Any sub-groups to enclose in this group. */ public void addSubgroup(T subgroup, int priority) { if(subgroup == null) { diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/delims/StringDelimiter.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/delims/StringDelimiter.java index cbf99ee..6db1c98 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/delims/StringDelimiter.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/delims/StringDelimiter.java @@ -12,7 +12,7 @@ public class StringDelimiter extends SequenceDelimiter<String> { /** * Override of - * {@link SequenceDelimiter#delimitSequence(Object, Object, Object...)} + * {@link SequenceDelimiter#delimitSequence(SequenceCharacteristics, Object...)} * for ease of use for strings. * * @param seq diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/PrattParser.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/PrattParser.java index e8543dc..20572e8 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/PrattParser.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/PrattParser.java @@ -36,8 +36,6 @@ public class PrattParser<K, V, C> { /** * Create a new Pratt parser. * - * @param terminal - * The terminal symbol. */ public PrattParser() { leftCommands = new HashMap<>(); |
