private final boolean evaluate(final byte[] expression, final ColumnVisibility.Node root) throws VisibilityParseException { if (expression.length == 0) return true; switch (root.type) { case TERM: return auths.contains(root.getTerm(expression)); case AND: if (root.children == null || root.children.size() < 2) throw new VisibilityParseException("AND has less than 2 children", expression, root.start); for (ColumnVisibility.Node child : root.children) { if (!evaluate(expression, child)) return false; } return true; case OR: if (root.children == null || root.children.size() < 2) throw new VisibilityParseException("OR has less than 2 children", expression, root.start); for (ColumnVisibility.Node child : root.children) { if (evaluate(expression, child)) return true; } return false; default: throw new VisibilityParseException("No such node type", expression, root.start); } } }
private final boolean evaluate(final byte[] expression, final ColumnVisibility.Node root) throws VisibilityParseException { if (expression.length == 0) return true; switch (root.type) { case TERM: return auths.contains(root.getTerm(expression)); case AND: if (root.children == null || root.children.size() < 2) throw new VisibilityParseException("AND has less than 2 children", expression, root.start); for (ColumnVisibility.Node child : root.children) { if (!evaluate(expression, child)) return false; } return true; case OR: if (root.children == null || root.children.size() < 2) throw new VisibilityParseException("OR has less than 2 children", expression, root.start); for (ColumnVisibility.Node child : root.children) { if (evaluate(expression, child)) return true; } return false; default: throw new VisibilityParseException("No such node type", expression, root.start); } } }