Search in sources :

Example 1 with NotExpression

use of com.yahoo.elide.core.security.permissions.expressions.NotExpression in project elide by yahoo.

the class PermissionExpressionNormalizationVisitor method visitNotExpression.

@Override
public Expression visitNotExpression(NotExpression notExpression) {
    Expression inner = notExpression.getLogical();
    if (inner instanceof AndExpression) {
        AndExpression and = (AndExpression) inner;
        Expression left = new NotExpression(and.getLeft()).accept(this);
        Expression right = new NotExpression(and.getRight()).accept(this);
        return new OrExpression(left, right);
    }
    if (inner instanceof OrExpression) {
        OrExpression or = (OrExpression) inner;
        Expression left = new NotExpression(or.getLeft()).accept(this);
        Expression right = new NotExpression(or.getRight()).accept(this);
        return new AndExpression(left, right);
    }
    if (inner instanceof NotExpression) {
        NotExpression not = (NotExpression) inner;
        return (not.getLogical()).accept(this);
    }
    return notExpression;
}
Also used : AndExpression(com.yahoo.elide.core.security.permissions.expressions.AndExpression) CheckExpression(com.yahoo.elide.core.security.permissions.expressions.CheckExpression) Expression(com.yahoo.elide.core.security.permissions.expressions.Expression) OrExpression(com.yahoo.elide.core.security.permissions.expressions.OrExpression) AndExpression(com.yahoo.elide.core.security.permissions.expressions.AndExpression) NotExpression(com.yahoo.elide.core.security.permissions.expressions.NotExpression) NotExpression(com.yahoo.elide.core.security.permissions.expressions.NotExpression) OrExpression(com.yahoo.elide.core.security.permissions.expressions.OrExpression)

Aggregations

AndExpression (com.yahoo.elide.core.security.permissions.expressions.AndExpression)1 CheckExpression (com.yahoo.elide.core.security.permissions.expressions.CheckExpression)1 Expression (com.yahoo.elide.core.security.permissions.expressions.Expression)1 NotExpression (com.yahoo.elide.core.security.permissions.expressions.NotExpression)1 OrExpression (com.yahoo.elide.core.security.permissions.expressions.OrExpression)1