keith-turner commented on code in PR #31:
URL: https://github.com/apache/accumulo-access/pull/31#discussion_r1465449627
##########
src/main/java/org/apache/accumulo/access/AccessExpressionImpl.java:
##########
@@ -20,99 +20,77 @@
import static java.nio.charset.StandardCharsets.UTF_8;
-import java.util.Arrays;
import java.util.HashSet;
-import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Predicate;
class AccessExpressionImpl implements AccessExpression {
- private final byte[] expression;
+ public static final AccessExpression EMPTY = new AccessExpressionImpl("",
false);
- final AeNode aeNode;
+ private final String expression;
- private final AtomicReference<String> expressionString = new
AtomicReference<>(null);
-
- @Override
- public String getExpression() {
- var expStr = expressionString.get();
- if (expStr != null) {
- return expStr;
+ AccessExpressionImpl(String expression, boolean normalize) {
+ if (normalize) {
+ // validate and normalize expression
+ this.expression = normalize(expression);
+ } else {
+ validate(expression);
+ this.expression = expression;
}
-
- return expressionString.updateAndGet(es -> es == null ? new
String(expression, UTF_8) : es);
}
- // must create this after creating EMPTY_NODE
- static final AccessExpression EMPTY = new AccessExpressionImpl("");
+ AccessExpressionImpl(byte[] expression, boolean normalize) {
+ if (normalize) {
+ // validate and normalize expression
+ this.expression = normalize(expression);
+ } else {
+ validate(expression);
+ this.expression = new String(expression, UTF_8);
+ }
Review Comment:
Did not call the string constructor because there are versions of the
normalize and validate method that take byte[]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]