From 28246517f475cea0e45a7030a0693a09d2dc1191 Mon Sep 17 00:00:00 2001 From: Sidhant Aggarwal <10743214+sidhant92@users.noreply.github.com> Date: Mon, 10 Jun 2024 20:23:55 +0530 Subject: [PATCH] remove logging and add info to errors --- build.gradle | 1 - .../ArithmeticExpressionEvaluator.java | 7 ++--- .../BooleanExpressionEvaluator.java | 17 ++++++----- .../constant/ContainerDataType.java | 3 -- .../boolparser/datatype/AbstractDataType.java | 2 -- .../exception/DataNotFoundException.java | 8 +++++- .../exception/InvalidExpressionException.java | 4 +++ .../exception/UnsupportedToken.java | 8 ++++-- .../function/FunctionEvaluatorService.java | 16 ++++------- .../boolparser/operator/OperatorService.java | 26 ++++++----------- .../operator/logical/ContainsAllOperator.java | 3 -- .../operator/logical/ContainsAnyOperator.java | 3 -- .../parser/antlr/BooleanFilterListener.java | 28 ++++++------------- .../sidhant92/boolparser/util/ValueUtils.java | 3 -- 14 files changed, 51 insertions(+), 78 deletions(-) diff --git a/build.gradle b/build.gradle index 05a46f0..acf6974 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,6 @@ repositories { } dependencies { - implementation 'ch.qos.logback:logback-classic:1.2.3' implementation 'org.apache.maven:maven-artifact:3.5.2' implementation 'org.antlr:antlr4-runtime:4.13.1' implementation 'io.vavr:vavr:0.10.4' diff --git a/src/main/java/com/github/sidhant92/boolparser/application/ArithmeticExpressionEvaluator.java b/src/main/java/com/github/sidhant92/boolparser/application/ArithmeticExpressionEvaluator.java index d9c670b..5da6ef0 100644 --- a/src/main/java/com/github/sidhant92/boolparser/application/ArithmeticExpressionEvaluator.java +++ b/src/main/java/com/github/sidhant92/boolparser/application/ArithmeticExpressionEvaluator.java @@ -19,13 +19,11 @@ import com.github.sidhant92.boolparser.parser.BoolExpressionParser; import com.github.sidhant92.boolparser.util.ValueUtils; import io.vavr.control.Try; -import lombok.extern.slf4j.Slf4j; /** * @author sidhant.aggarwal * @since 15/03/2024 */ -@Slf4j public class ArithmeticExpressionEvaluator { private final BoolExpressionParser boolExpressionParser; @@ -59,14 +57,13 @@ private Object evaluateToken(final Node node, final Map data) { case FIELD: return evaluateFieldToken((FieldNode) node, data); default: - log.error("unsupported token {}", node.getTokenType()); - throw new UnsupportedToken(); + throw new UnsupportedToken(node.getTokenType().name()); } } private Object evaluateFieldToken(final FieldNode fieldNode, final Map data) { if (!data.containsKey(fieldNode.getField())) { - throw new DataNotFoundException(); + throw new DataNotFoundException(fieldNode.getField()); } return data.get(fieldNode.getField()); } diff --git a/src/main/java/com/github/sidhant92/boolparser/application/BooleanExpressionEvaluator.java b/src/main/java/com/github/sidhant92/boolparser/application/BooleanExpressionEvaluator.java index 142639c..d9120c4 100644 --- a/src/main/java/com/github/sidhant92/boolparser/application/BooleanExpressionEvaluator.java +++ b/src/main/java/com/github/sidhant92/boolparser/application/BooleanExpressionEvaluator.java @@ -22,13 +22,11 @@ import com.github.sidhant92.boolparser.parser.BoolExpressionParser; import com.github.sidhant92.boolparser.util.ValueUtils; import io.vavr.control.Try; -import lombok.extern.slf4j.Slf4j; /** * @author sidhant.aggarwal * @since 07/02/2023 */ -@Slf4j public class BooleanExpressionEvaluator { private final BoolExpressionParser boolExpressionParser; @@ -71,7 +69,8 @@ private boolean evaluateToken(final Node node, final Map data) { } private boolean evaluateComparisonToken(final ComparisonNode comparisonToken, final Map data) { - final Object fieldData = ValueUtils.getValueFromMap(comparisonToken.getField(), data).orElseThrow(DataNotFoundException::new); + final Object fieldData = ValueUtils.getValueFromMap(comparisonToken.getField(), data) + .orElseThrow(() -> new DataNotFoundException(comparisonToken.getField())); final Object value = comparisonToken.getValue() instanceof ArithmeticBaseNode ? arithmeticExpressionEvaluator.evaluate( comparisonToken.getValue(), data) : comparisonToken.getValue(); return operatorService.evaluateLogicalOperator(comparisonToken.getOperator(), ContainerDataType.PRIMITIVE, comparisonToken.getDataType(), @@ -79,14 +78,16 @@ private boolean evaluateComparisonToken(final ComparisonNode comparisonToken, fi } private boolean evaluateNumericRangeToken(final NumericRangeNode numericRangeToken, final Map data) { - final Object fieldData = ValueUtils.getValueFromMap(numericRangeToken.getField(), data).orElseThrow(DataNotFoundException::new); + final Object fieldData = ValueUtils.getValueFromMap(numericRangeToken.getField(), data) + .orElseThrow(() -> new DataNotFoundException(numericRangeToken.getField())); return operatorService.evaluateLogicalOperator(Operator.GREATER_THAN_EQUAL, ContainerDataType.PRIMITIVE, numericRangeToken.getFromDataType(), fieldData, numericRangeToken.getFromValue()) && operatorService.evaluateLogicalOperator( Operator.LESS_THAN_EQUAL, ContainerDataType.PRIMITIVE, numericRangeToken.getToDataType(), fieldData, numericRangeToken.getToValue()); } private boolean evaluateInToken(final InNode inToken, final Map data) { - final Object fieldData = ValueUtils.getValueFromMap(inToken.getField(), data).orElseThrow(DataNotFoundException::new); + final Object fieldData = ValueUtils.getValueFromMap(inToken.getField(), data) + .orElseThrow(() -> new DataNotFoundException(inToken.getField())); final List items = resolveArrayElements(inToken.getItems(), data); final DataType dataType = ValueUtils.getDataType(fieldData); final Object[] values = items @@ -109,7 +110,8 @@ private List resolveArrayElements(final List items, final M } private boolean evaluateArrayToken(final ArrayNode arrayNode, final Map data) { - final Object fieldData = ValueUtils.getValueFromMap(arrayNode.getField(), data).orElseThrow(DataNotFoundException::new); + final Object fieldData = ValueUtils.getValueFromMap(arrayNode.getField(), data) + .orElseThrow(() -> new DataNotFoundException(arrayNode.getField())); final List items = resolveArrayElements(arrayNode.getItems(), data); if (items .stream() @@ -127,7 +129,8 @@ private boolean evaluateUnaryToken(final UnaryNode unaryToken, final Map new DataNotFoundException(unaryToken.getValue().toString())); if (!(fieldData instanceof Boolean)) { throw new InvalidUnaryOperand(); } diff --git a/src/main/java/com/github/sidhant92/boolparser/constant/ContainerDataType.java b/src/main/java/com/github/sidhant92/boolparser/constant/ContainerDataType.java index 98c4e09..5f99aa9 100644 --- a/src/main/java/com/github/sidhant92/boolparser/constant/ContainerDataType.java +++ b/src/main/java/com/github/sidhant92/boolparser/constant/ContainerDataType.java @@ -10,7 +10,6 @@ import com.github.sidhant92.boolparser.exception.InvalidDataType; import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.extern.slf4j.Slf4j; /** * @author sidhant.aggarwal @@ -18,14 +17,12 @@ */ @Getter @AllArgsConstructor -@Slf4j public enum ContainerDataType { PRIMITIVE() { @Override public Optional getValue(final DataType dataType, final Object value) { final Optional result = DataTypeFactory.getDataType(dataType).getValue(value); if (!result.isPresent()) { - log.error("Invalid data type for value {} for data type {}", value.toString(), dataType.name()); throw new InvalidDataType(String.format("Invalid data type for value %s for data type %s", value, dataType.name())); } return result; diff --git a/src/main/java/com/github/sidhant92/boolparser/datatype/AbstractDataType.java b/src/main/java/com/github/sidhant92/boolparser/datatype/AbstractDataType.java index 3775e5d..bdc8cd4 100644 --- a/src/main/java/com/github/sidhant92/boolparser/datatype/AbstractDataType.java +++ b/src/main/java/com/github/sidhant92/boolparser/datatype/AbstractDataType.java @@ -2,13 +2,11 @@ import java.util.Optional; import com.github.sidhant92.boolparser.constant.DataType; -import lombok.extern.slf4j.Slf4j; /** * @author sidhant.aggarwal * @since 05/03/2023 */ -@Slf4j public abstract class AbstractDataType> { private final Class clazz; diff --git a/src/main/java/com/github/sidhant92/boolparser/exception/DataNotFoundException.java b/src/main/java/com/github/sidhant92/boolparser/exception/DataNotFoundException.java index ceca473..943f31e 100644 --- a/src/main/java/com/github/sidhant92/boolparser/exception/DataNotFoundException.java +++ b/src/main/java/com/github/sidhant92/boolparser/exception/DataNotFoundException.java @@ -1,8 +1,14 @@ package com.github.sidhant92.boolparser.exception; public class DataNotFoundException extends RuntimeException { + private static final String MESSAGE = "Data not found"; + + public DataNotFoundException(final String key) { + super(String.format(MESSAGE + " for the key %s", key)); + } + @Override public String getMessage() { - return "Data not found"; + return MESSAGE; } } diff --git a/src/main/java/com/github/sidhant92/boolparser/exception/InvalidExpressionException.java b/src/main/java/com/github/sidhant92/boolparser/exception/InvalidExpressionException.java index 84c7849..1998be8 100644 --- a/src/main/java/com/github/sidhant92/boolparser/exception/InvalidExpressionException.java +++ b/src/main/java/com/github/sidhant92/boolparser/exception/InvalidExpressionException.java @@ -1,6 +1,10 @@ package com.github.sidhant92.boolparser.exception; public class InvalidExpressionException extends RuntimeException { + public InvalidExpressionException(final String message) { + super(message); + } + @Override public String getMessage() { return "Invalid Expression"; diff --git a/src/main/java/com/github/sidhant92/boolparser/exception/UnsupportedToken.java b/src/main/java/com/github/sidhant92/boolparser/exception/UnsupportedToken.java index 69a29bc..5df330f 100644 --- a/src/main/java/com/github/sidhant92/boolparser/exception/UnsupportedToken.java +++ b/src/main/java/com/github/sidhant92/boolparser/exception/UnsupportedToken.java @@ -1,8 +1,10 @@ package com.github.sidhant92.boolparser.exception; public class UnsupportedToken extends RuntimeException { - public UnsupportedToken(final String message) { - super(message); + private static final String MESSAGE = "Unsupported Token"; + + public UnsupportedToken(final String token) { + super(String.format(MESSAGE + " %s", token)); } public UnsupportedToken() { @@ -11,6 +13,6 @@ public UnsupportedToken() { @Override public String getMessage() { - return "Unsupported Token"; + return MESSAGE; } } diff --git a/src/main/java/com/github/sidhant92/boolparser/function/FunctionEvaluatorService.java b/src/main/java/com/github/sidhant92/boolparser/function/FunctionEvaluatorService.java index bd3e4fc..83d10e2 100644 --- a/src/main/java/com/github/sidhant92/boolparser/function/FunctionEvaluatorService.java +++ b/src/main/java/com/github/sidhant92/boolparser/function/FunctionEvaluatorService.java @@ -10,13 +10,11 @@ import com.github.sidhant92.boolparser.exception.InvalidDataType; import com.github.sidhant92.boolparser.exception.InvalidExpressionException; import com.github.sidhant92.boolparser.function.arithmetic.AbstractFunction; -import lombok.extern.slf4j.Slf4j; /** * @author sidhant.aggarwal * @since 21/05/2024 */ -@Slf4j public class FunctionEvaluatorService { public FunctionEvaluatorService() { FunctionFactory.initialize(); @@ -25,25 +23,23 @@ public FunctionEvaluatorService() { public Object evaluateArithmeticFunction(final FunctionType functionType, final List items) { final AbstractFunction abstractFunction = FunctionFactory.getArithmeticFunction(functionType); if (items.isEmpty()) { - log.error("Empty items not allowed"); - throw new InvalidExpressionException(); + throw new InvalidExpressionException("Empty items not allowed"); } final ContainerDataType containerDataType = items.size() > 1 ? ContainerDataType.LIST : ContainerDataType.PRIMITIVE; if (!abstractFunction.getAllowedContainerTypes().contains(containerDataType)) { - log.error("Invalid container type {} for function {}", containerDataType, functionType.name()); - throw new InvalidContainerTypeException(); + throw new InvalidContainerTypeException( + String.format("Invalid container type %s for function %s", containerDataType, functionType.name())); } final boolean validDataType = items .stream().allMatch(item -> abstractFunction.getAllowedDataTypes().contains(item.getDataType())); if (!validDataType) { - log.error("Invalid data type {} for function {}", items, functionType.name()); - throw new InvalidDataType(); + throw new InvalidDataType(String.format("Invalid data type for function %s", functionType.name())); } items.forEach(item -> { if (!ContainerDataType.PRIMITIVE.isValid(item.getDataType(), item.getValue())) { - log.error("Validation failed for the function {} for the operand {}", functionType.name(), item.getValue()); - throw new InvalidDataType(); + throw new InvalidDataType( + String.format("Validation failed for the function %s for the operand %s", functionType.name(), item.getValue())); } }); return abstractFunction.evaluate(items); diff --git a/src/main/java/com/github/sidhant92/boolparser/operator/OperatorService.java b/src/main/java/com/github/sidhant92/boolparser/operator/OperatorService.java index 57d5853..a685ae0 100644 --- a/src/main/java/com/github/sidhant92/boolparser/operator/OperatorService.java +++ b/src/main/java/com/github/sidhant92/boolparser/operator/OperatorService.java @@ -8,13 +8,11 @@ import com.github.sidhant92.boolparser.exception.InvalidContainerTypeException; import com.github.sidhant92.boolparser.exception.InvalidDataType; import com.github.sidhant92.boolparser.operator.logical.AbstractOperator; -import lombok.extern.slf4j.Slf4j; /** * @author sidhant.aggarwal * @since 05/03/2023 */ -@Slf4j public class OperatorService { public OperatorService() { DataTypeFactory.initialize(); @@ -25,16 +23,13 @@ public boolean evaluateLogicalOperator(final Operator operator, final ContainerD final Object leftOperand, final Object... rightOperands) { final AbstractOperator abstractOperator = OperatorFactory.getLogicalOperator(operator); if (!abstractOperator.getAllowedContainerTypes().contains(containerDataType)) { - log.error("Invalid left container type {} for operator {}", containerDataType, operator); - throw new InvalidContainerTypeException(); + throw new InvalidContainerTypeException(String.format("Invalid left container type %s for operator %s", containerDataType, operator)); } if (!abstractOperator.getAllowedDataTypes().contains(dataType)) { - log.error("Invalid left operand data type {} for operator {}", dataType, operator); - throw new InvalidDataType(); + throw new InvalidDataType(String.format("Invalid left operand data type %s for operator %s", dataType, operator)); } if (!containerDataType.isValid(dataType, leftOperand)) { - log.error("Validation failed for the operator {} for the operand {}", operator, leftOperand); - throw new InvalidDataType(); + throw new InvalidDataType(String.format("Validation failed for the operator %s for the operand %s", operator, leftOperand)); } return OperatorFactory.getLogicalOperator(operator).evaluate(containerDataType, dataType, leftOperand, rightOperands); } @@ -43,24 +38,19 @@ public Object evaluateArithmeticOperator(final Object leftOperand, final DataTyp final DataType rightDataType, final Operator operator, final ContainerDataType containerDataType) { final com.github.sidhant92.boolparser.operator.arithmetic.AbstractOperator abstractOperator = OperatorFactory.getArithmeticOperator(operator); if (!abstractOperator.getAllowedContainerTypes().contains(containerDataType)) { - log.error("Invalid left container type {} for operator {}", containerDataType, operator); - throw new InvalidContainerTypeException(); + throw new InvalidContainerTypeException(String.format("Invalid left container type %s for operator %s", containerDataType, operator)); } if (!abstractOperator.getAllowedDataTypes().contains(leftDataType)) { - log.error("Invalid left operand data type {} for operator {}", leftDataType, operator); - throw new InvalidDataType(); + throw new InvalidDataType(String.format("Invalid left operand data type %s for operator %s", leftDataType, operator)); } if (!containerDataType.isValid(leftDataType, leftOperand)) { - log.error("Validation failed for the operator {} for the operand {}", operator, leftOperand); - throw new InvalidDataType(); + throw new InvalidDataType(String.format("Validation failed for the operator %s for the operand %s", operator, leftOperand)); } if (Objects.nonNull(rightDataType) && !abstractOperator.getAllowedDataTypes().contains(rightDataType)) { - log.error("Invalid left operand data type {} for operator {}", rightDataType, operator); - throw new InvalidDataType(); + throw new InvalidDataType(String.format("Invalid left operand data type %s for operator %s", rightDataType, operator)); } if (Objects.nonNull(rightOperand) && !containerDataType.isValid(rightDataType, rightOperand)) { - log.error("Validation failed for the operator {} for the operand {}", operator, rightDataType); - throw new InvalidDataType(); + throw new InvalidDataType(String.format("Validation failed for the operator %s for the operand %s", operator, rightDataType)); } return OperatorFactory.getArithmeticOperator(operator).evaluate(leftOperand, leftDataType, rightOperand, rightDataType); } diff --git a/src/main/java/com/github/sidhant92/boolparser/operator/logical/ContainsAllOperator.java b/src/main/java/com/github/sidhant92/boolparser/operator/logical/ContainsAllOperator.java index 337bb19..c4315e8 100644 --- a/src/main/java/com/github/sidhant92/boolparser/operator/logical/ContainsAllOperator.java +++ b/src/main/java/com/github/sidhant92/boolparser/operator/logical/ContainsAllOperator.java @@ -7,10 +7,8 @@ import com.github.sidhant92.boolparser.constant.DataType; import com.github.sidhant92.boolparser.constant.Operator; import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; @AllArgsConstructor -@Slf4j public class ContainsAllOperator extends AbstractOperator { private final InOperator inOperator; @@ -18,7 +16,6 @@ public class ContainsAllOperator extends AbstractOperator { public > boolean evaluate(final ContainerDataType containerDataType, final DataType dataType, final Object leftOperand, final Object... rightOperands) { if (!containerDataType.isValid(dataType, leftOperand)) { - log.error("Validation failed for any operator for the operand {}", leftOperand); return false; } final Object[] leftOperandArray = ((List) leftOperand).toArray(); diff --git a/src/main/java/com/github/sidhant92/boolparser/operator/logical/ContainsAnyOperator.java b/src/main/java/com/github/sidhant92/boolparser/operator/logical/ContainsAnyOperator.java index 81bf8d9..d5039d1 100644 --- a/src/main/java/com/github/sidhant92/boolparser/operator/logical/ContainsAnyOperator.java +++ b/src/main/java/com/github/sidhant92/boolparser/operator/logical/ContainsAnyOperator.java @@ -7,10 +7,8 @@ import com.github.sidhant92.boolparser.constant.DataType; import com.github.sidhant92.boolparser.constant.Operator; import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; @AllArgsConstructor -@Slf4j public class ContainsAnyOperator extends AbstractOperator { private final InOperator inOperator; @@ -18,7 +16,6 @@ public class ContainsAnyOperator extends AbstractOperator { public > boolean evaluate(final ContainerDataType containerDataType, final DataType dataType, final Object leftOperand, final Object... rightOperands) { if (!containerDataType.isValid(dataType, leftOperand)) { - log.error("Validation failed for any operator for the operand {}", leftOperand); return false; } final Object[] leftOperandArray = ((List) leftOperand).toArray(); diff --git a/src/main/java/com/github/sidhant92/boolparser/parser/antlr/BooleanFilterListener.java b/src/main/java/com/github/sidhant92/boolparser/parser/antlr/BooleanFilterListener.java index 7235231..9c01395 100644 --- a/src/main/java/com/github/sidhant92/boolparser/parser/antlr/BooleanFilterListener.java +++ b/src/main/java/com/github/sidhant92/boolparser/parser/antlr/BooleanFilterListener.java @@ -25,9 +25,7 @@ import com.github.sidhant92.boolparser.domain.arithmetic.UnaryNode; import com.github.sidhant92.boolparser.exception.InvalidExpressionException; import com.github.sidhant92.boolparser.util.ValueUtils; -import lombok.extern.slf4j.Slf4j; -@Slf4j public class BooleanFilterListener extends BooleanExpressionBaseListener { private Node node; @@ -37,7 +35,7 @@ public class BooleanFilterListener extends BooleanExpressionBaseListener { private int tokenCount; - private String defaultField; + private final String defaultField; public BooleanFilterListener(final String defaultField) { this.defaultField = defaultField; @@ -123,8 +121,7 @@ private Node mapContextToNode(final ParseTree ctx) { } else if (ctx instanceof BooleanExpressionParser.TypesExpressionContext) { return mapTypesExpressionContext((BooleanExpressionParser.TypesExpressionContext) ctx); } else { - log.error("Array does not support this expression {}", ctx.getText()); - throw new InvalidExpressionException(); + throw new InvalidExpressionException(String.format("Array does not support this expression %s", ctx.getText())); } } @@ -143,12 +140,10 @@ private Node mapTypesExpressionContext(BooleanExpressionParser.TypesExpressionCo private ArithmeticFunctionNode mapArithmeticFunctionExpressionContext(BooleanExpressionParser.ArithmeticFunctionExpressionContext ctx) { if (ctx.data.exception != null) { - log.error("Error parsing expression for the string {}", ctx.getText()); - throw new InvalidExpressionException(); + throw new InvalidExpressionException(String.format("Error parsing expression for the string %s", ctx.getText())); } final FunctionType functionType = FunctionType.getArrayFunctionFromSymbol(ctx.left.getText()).orElseThrow(() -> { - log.error("Error parsing expression for the string {}", ctx.getText()); - return new InvalidExpressionException(); + return new InvalidExpressionException(String.format("Error parsing expression for the string %s", ctx.getText())); }); final List items = getArrayElements(ctx.data.children); return new ArithmeticFunctionNode(functionType, items); @@ -183,8 +178,7 @@ private ArithmeticNode mapArithmeticExpressionContext(BooleanExpressionParser.Ar return ArithmeticNode.builder().left(left).right(right).operator(operator).build(); } else { if (currentNodes.size() < 2) { - log.error("Error parsing expression for the string {}", ctx.getText()); - throw new InvalidExpressionException(); + throw new InvalidExpressionException(String.format("Error parsing expression for the string %s", ctx.getText())); } final Node right = currentNodes.pop(); final Node left = currentNodes.pop(); @@ -216,8 +210,7 @@ private NumericRangeNode mapToExpressionContext(BooleanExpressionParser.ToExpres private void validateField(final Token token, final String text) { if (Objects.isNull(token) || (StringUtils.isBlank(token.getText()) && StringUtils.isBlank(this.defaultField))) { - log.error("Error parsing expression (missing field) for the string {}", text); - throw new InvalidExpressionException(); + throw new InvalidExpressionException(String.format("Error parsing expression (missing field) for the string %s", text)); } } @@ -262,8 +255,7 @@ public void exitParse(BooleanExpressionParser.ParseContext ctx) { .builder().dataType(DataType.STRING).value(ValueUtils.convertValue(lastToken.getText(), DataType.STRING).toString()).build(); } if (this.node == null) { - log.error("Error parsing expression for the string {}", ctx.getText()); - throw new InvalidExpressionException(); + throw new InvalidExpressionException(String.format("Error parsing expression for the string %s", ctx.getText())); } super.exitParse(ctx); } @@ -272,8 +264,7 @@ public void exitParse(BooleanExpressionParser.ParseContext ctx) { public void exitNotExpression(BooleanExpressionParser.NotExpressionContext ctx) { if (currentNodes.isEmpty()) { if (lastToken == null) { - log.error("Error parsing not expression for the string {}", ctx.getText()); - throw new InvalidExpressionException(); + throw new InvalidExpressionException(String.format("Error parsing not expression for the string %s", ctx.getText())); } final DataType dataType = getDataType(lastToken); final Object value = ValueUtils.convertValue(lastToken.getText(), dataType); @@ -293,8 +284,7 @@ public void exitTypesExpression(BooleanExpressionParser.TypesExpressionContext c @Override public void exitBinaryExpression(BooleanExpressionParser.BinaryExpressionContext ctx) { if (currentNodes.size() < 2) { - log.error("Error parsing binary expression for the string {}", ctx.getText()); - throw new InvalidExpressionException(); + throw new InvalidExpressionException(String.format("Error parsing binary expression for the string %s", ctx.getText())); } final Node firstNode = currentNodes.pop(); final Node secondNode = currentNodes.pop(); diff --git a/src/main/java/com/github/sidhant92/boolparser/util/ValueUtils.java b/src/main/java/com/github/sidhant92/boolparser/util/ValueUtils.java index cd9efe5..5523469 100644 --- a/src/main/java/com/github/sidhant92/boolparser/util/ValueUtils.java +++ b/src/main/java/com/github/sidhant92/boolparser/util/ValueUtils.java @@ -10,9 +10,7 @@ import org.apache.maven.artifact.versioning.ComparableVersion; import com.github.sidhant92.boolparser.constant.DataType; import com.github.sidhant92.boolparser.domain.EvaluatedNode; -import lombok.extern.slf4j.Slf4j; -@Slf4j public class ValueUtils { public static Optional getValueFromMap(final String key, final Map data) { final String[] keys = key.split("\\."); @@ -31,7 +29,6 @@ public static Optional getValueFromMap(final String key, final Map