Source:
<code>private FormulaElement term() throws InternFormulaParserException { FormulaElement termTree = new FormulaElement(FormulaElement.ElementType.NUMBER, null, null); FormulaElement currentElement = termTree; if (currentToken.isOperator() && currentToken.getTokenStringValue().equals(Operators.MINUS.name())) { currentElement = new FormulaElement(FormulaElement.ElementType.NUMBER, null, termTree, null, null); termTree.replaceElement(new FormulaElement(FormulaElement.ElementType.OPERATOR, Operators.MINUS.name(), null, null, currentElement)); getNextToken(); } else if (currentToken.isOperator() && currentToken.getTokenStringValue().equals(Operators.LOGICAL_NOT.name())) { currentElement = new FormulaElement(FormulaElement.ElementType.NUMBER, null, termTree, null, null); termTree.replaceElement(new FormulaElement(FormulaElement.ElementType.OPERATOR, Operators.LOGICAL_NOT .name(), null, null, currentElement)); getNextToken(); } switch (currentToken.getInternTokenType()) { case NUMBER: currentElement.replaceElement(FormulaElement.ElementType.NUMBER, number()); break; case BRACKET_OPEN: getNextToken(); <START> currentElement.replaceElement(new FormulaElement(FormulaElement.ElementType.BRACKET, "", null, null, <END> termList())); if (!currentToken.isBracketClose()) { throw new InternFormulaParserException("Parse Error"); } getNextToken(); break; case FUNCTION_NAME: currentElement.replaceElement(function()); break; case SENSOR: currentElement.replaceElement(sensor()); break; case USER_VARIABLE: currentElement.replaceElement(userVariable()); break; case USER_LIST: currentElement.replaceElement(userList()); break; case STRING: currentElement.replaceElement(FormulaElement.ElementType.STRING, string()); break; case COLLISION_FORMULA: currentElement.replaceElement(collision()); break; default: throw new InternFormulaParserException("Parse Error"); } return termTree; }</code><technical_language>this nicer if youd fix this checking for null in stringWithoutTrailingZero, call "getValue" save for kinds of tokens</technical_language>

Target:
private FormulaElement term() throws InternFormulaParserException { FormulaElement termTree = new FormulaElement(FormulaElement.ElementType.NUMBER, null, null); FormulaElement currentElement = termTree; if (currentToken.isOperator() && currentToken.getTokenStringValue().equals(Operators.MINUS.name())) { currentElement = new FormulaElement(FormulaElement.ElementType.NUMBER, null, termTree, null, null); termTree.replaceElement(new FormulaElement(FormulaElement.ElementType.OPERATOR, Operators.MINUS.name(), null, null, currentElement)); getNextToken(); } else if (currentToken.isOperator() && currentToken.getTokenStringValue().equals(Operators.LOGICAL_NOT.name())) { currentElement = new FormulaElement(FormulaElement.ElementType.NUMBER, null, termTree, null, null); termTree.replaceElement(new FormulaElement(FormulaElement.ElementType.OPERATOR, Operators.LOGICAL_NOT .name(), null, null, currentElement)); getNextToken(); } switch (currentToken.getInternTokenType()) { case NUMBER: currentElement.replaceElement(FormulaElement.ElementType.NUMBER, number()); break; case BRACKET_OPEN: getNextToken(); currentElement.replaceElement(new FormulaElement(FormulaElement.ElementType.BRACKET, null, null, null, termList())); if (!currentToken.isBracketClose()) { throw new InternFormulaParserException("Parse Error"); } getNextToken(); break; case FUNCTION_NAME: currentElement.replaceElement(function()); break; case SENSOR: currentElement.replaceElement(sensor()); break; case USER_VARIABLE: currentElement.replaceElement(userVariable()); break; case USER_LIST: currentElement.replaceElement(userList()); break; case STRING: currentElement.replaceElement(FormulaElement.ElementType.STRING, string()); break; case COLLISION_FORMULA: currentElement.replaceElement(collision()); break; default: throw new InternFormulaParserException("Parse Error"); } return termTree; }