From 889fac2bdf993dc86f64a8893c0260fdcf848acb Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 10 Apr 2017 16:40:33 -0400 Subject: Cleanup --- .../bjc/utils/parserutils/TreeConstructor.java | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java index bd0ab97..d7ed5b0 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/TreeConstructor.java @@ -1,5 +1,10 @@ package bjc.utils.parserutils; +import java.util.Deque; +import java.util.LinkedList; +import java.util.function.Function; +import java.util.function.Predicate; + import bjc.utils.data.IHolder; import bjc.utils.data.IPair; import bjc.utils.data.ITree; @@ -7,11 +12,6 @@ import bjc.utils.data.Identity; import bjc.utils.data.Pair; import bjc.utils.funcdata.IList; -import java.util.Deque; -import java.util.LinkedList; -import java.util.function.Function; -import java.util.function.Predicate; - /** * Creates a parse tree from a postfix expression * @@ -21,7 +21,7 @@ import java.util.function.Predicate; public class TreeConstructor { /** * Alias interface for special operator types. - * + * * @param * The token type of the tree. */ @@ -33,11 +33,11 @@ public class TreeConstructor { * Alias for constructor state. */ static final class ConstructorState extends Pair>, ITree> { - public ConstructorState(Deque> left, ITree right) { + public ConstructorState(final Deque> left, final ITree right) { super(left, right); } - public ConstructorState(IPair>, ITree> par) { + public ConstructorState(final IPair>, ITree> par) { super(par.getLeft(), par.getRight()); } } @@ -56,8 +56,8 @@ public class TreeConstructor { * operator * @return A AST from the expression */ - public static ITree constructTree(IList tokens, - Predicate isOperator) { + public static ITree constructTree(final IList tokens, + final Predicate isOperator) { // Construct a tree with no special operators return constructTree(tokens, isOperator, op -> false, null); } @@ -70,37 +70,37 @@ public class TreeConstructor { * * @param * The elements of the parse tree. - * + * * @param tokens * The list of tokens to build a tree from. - * + * * @param isOperator * The predicate to use to determine if something is a * operator. - * + * * @param isSpecialOperator * The predicate to use to determine if an operator needs * special handling. - * + * * @param handleSpecialOperator * The function to use to handle special case operators. - * + * * @return A AST from the expression * */ - public static ITree constructTree(IList tokens, - Predicate isOperator, Predicate isSpecialOperator, - Function> handleSpecialOperator) { + public static ITree constructTree(final IList tokens, + final Predicate isOperator, final Predicate isSpecialOperator, + final Function> handleSpecialOperator) { // Make sure our parameters are valid - if(tokens == null) + if (tokens == null) throw new NullPointerException("Tokens must not be null"); - else if(isOperator == null) + else if (isOperator == null) throw new NullPointerException("Operator predicate must not be null"); - else if(isSpecialOperator == null) + else if (isSpecialOperator == null) throw new NullPointerException("Special operator determiner must not be null"); // Here is the state for the tree construction - IHolder> initialState = new Identity<>( + final IHolder> initialState = new Identity<>( new ConstructorState<>(new LinkedList<>(), null)); // Transform each of the tokens -- cgit v1.2.3