net.hasor.db.jsqlparser.expression.CaseExpression Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hasor-db Show documentation
Show all versions of hasor-db Show documentation
the hasor DataBase project.
/*-
* #%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;
import java.util.List;
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
import net.sf.jsqlparser.statement.select.PlainSelect;
/**
* CASE/WHEN expression.
*
* Syntax:
* CASE
* WHEN condition THEN expression
* [WHEN condition THEN expression]...
* [ELSE expression]
* END
*
*
*
* or
*
*
*
* CASE expression
* WHEN condition THEN expression
* [WHEN condition THEN expression]...
* [ELSE expression]
* END
*
*
*/
public class CaseExpression extends ASTNodeAccessImpl implements Expression {
private Expression switchExpression;
private List whenClauses;
private Expression elseExpression;
@Override
public void accept(ExpressionVisitor expressionVisitor) {
expressionVisitor.visit(this);
}
public Expression getSwitchExpression() {
return switchExpression;
}
public void setSwitchExpression(Expression switchExpression) {
this.switchExpression = switchExpression;
}
/**
* @return Returns the elseExpression.
*/
public Expression getElseExpression() {
return elseExpression;
}
/**
* @param elseExpression The elseExpression to set.
*/
public void setElseExpression(Expression elseExpression) {
this.elseExpression = elseExpression;
}
/**
* @return Returns the whenClauses.
*/
public List getWhenClauses() {
return whenClauses;
}
/**
* @param whenClauses The whenClauses to set.
*/
public void setWhenClauses(List whenClauses) {
this.whenClauses = whenClauses;
}
@Override
public String toString() {
return "CASE " + ((switchExpression != null) ? switchExpression + " " : "")
+ PlainSelect.getStringList(whenClauses, false, false) + " "
+ ((elseExpression != null) ? "ELSE " + elseExpression + " " : "") + "END";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy