ddanielr commented on code in PR #5293:
URL: https://github.com/apache/accumulo/pull/5293#discussion_r1934746834


##########
core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java:
##########
@@ -505,6 +524,31 @@ public ColumnVisibility(byte[] expression) {
     validate(expression);
   }
 
+  /**
+   * Creates a column visibility for a Mutation from an AccessExpression.
+   *
+   * @param expression visibility expression, encoded as UTF-8 bytes
+   * @see #ColumnVisibility(String)
+   * @since 2.1.4
+   */
+  public ColumnVisibility(AccessExpression expression) {
+    // AccessExpression is a validated immutable object, so no need to re 
validate
+    this.expression = expression.getExpression().getBytes(UTF_8);

Review Comment:
   > Considering that we already have a `ColumnVisibility(byte[])` constructor, 
we would likely need to create a `ColumnVisibility(byte[], boolean)` 
constructor.
   
   I added that constructor but made it private. Then I added a new static 
method to use the private constructor called `fromAccessExpression` so that 
creation of these unvalidated ColumnVisibilities is very explicit.
   
   ```
   public static ColumnVisibility fromAccessExpression(byte[] 
incomingExpression) {
       return new ColumnVisibility(incomingExpression, false);
     }
   ```
   
   The name should probably be changed, so I'm open to suggestions.



-- 
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]

Reply via email to