IsBooleanExpression.java
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2019 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.expression.operators.relational;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.ExpressionVisitor;
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
public class IsBooleanExpression extends ASTNodeAccessImpl implements Expression {
private Expression leftExpression;
private boolean not = false;
private boolean isTrue = false;
public Expression getLeftExpression() {
return leftExpression;
}
public void setLeftExpression(Expression expression) {
leftExpression = expression;
}
public boolean isNot() {
return not;
}
public void setNot(boolean b) {
not = b;
}
public boolean isTrue() {
return isTrue;
}
public void setIsTrue(boolean isTrue) {
this.isTrue = isTrue;
}
@Override
public <T, S> T accept(ExpressionVisitor<T> expressionVisitor, S context) {
return expressionVisitor.visit(this, context);
}
@Override
public String toString() {
if (isTrue()) {
return leftExpression + " IS" + (not ? " NOT" : "") + " TRUE";
} else {
return leftExpression + " IS" + (not ? " NOT" : "") + " FALSE";
}
}
public IsBooleanExpression withIsTrue(boolean isTrue) {
this.setIsTrue(isTrue);
return this;
}
public IsBooleanExpression withLeftExpression(Expression leftExpression) {
this.setLeftExpression(leftExpression);
return this;
}
public IsBooleanExpression withNot(boolean not) {
this.setNot(not);
return this;
}
public <E extends Expression> E getLeftExpression(Class<E> type) {
return type.cast(getLeftExpression());
}
}