use of org.apache.ratis.thirdparty.com.google.common.annotations.VisibleForTesting in project incubator-ratis by apache.
the class Assign method createExpression.
@VisibleForTesting
Expression createExpression(String val) {
if (NUMBER_PATTERN.matcher(val).matches()) {
return new DoubleValue(Double.parseDouble(val));
} else if (Variable.PATTERN.matcher(val).matches()) {
return new Variable(val);
}
Matcher binaryMatcher = BINARY_OPERATION_PATTERN.matcher(val);
Matcher unaryMatcher = UNARY_OPERATION_PATTERN.matcher(val);
if (binaryMatcher.matches()) {
return createBinaryExpression(binaryMatcher);
} else if (unaryMatcher.matches()) {
return createUnaryExpression(unaryMatcher);
} else {
throw new IllegalArgumentException("Invalid expression " + val + " Try something like: 'a+b' or '2'");
}
}
Aggregations