com.evuv.expressions.NotExpression Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of evuv-exp-parser Show documentation
Show all versions of evuv-exp-parser Show documentation
Boolean expression parser and evaluator
The newest version!
package com.evuv.expressions;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import com.evuv.exceptions.EventBindingException;
public class NotExpression implements Expression, BindedExpression {
protected Expression node;
public NotExpression(){}
public NotExpression(Expression node) {
this.node = node;
}
@SuppressWarnings("unchecked")
@Override
public Boolean getValue() {
return !((BindedExpression)node).getValue();
}
@SuppressWarnings("rawtypes")
@Override
public Expression getLeft() {
return node;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void setLeft(Expression left) {
this.node = left;
}
@SuppressWarnings("rawtypes")
@Override
public Expression getRight() {
return node;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void setRight(Expression right) {
this.node = right;
}
@Override
public List toFlatExression() {
List res = new LinkedList();
List nodeExpr = node.toFlatExression();
if (nodeExpr != null ) {
res.addAll(nodeExpr);
}
return res;
}
@SuppressWarnings("unchecked")
@Override
public NotExpression bind(Map event) throws EventBindingException {
BindedExpression newNode = node.bind(event);
return new NotExpression((Expression)newNode);
}
}