net.hasor.db.jsqlparser.expression.KeepExpression 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 net.sf.jsqlparser.parser.ASTNodeAccessImpl;
import net.sf.jsqlparser.statement.select.OrderByElement;
import java.util.List;
public class KeepExpression extends ASTNodeAccessImpl implements Expression {
private String name;
private List orderByElements;
private boolean first = false;
@Override
public void accept(ExpressionVisitor expressionVisitor) {
expressionVisitor.visit(this);
}
public List getOrderByElements() {
return orderByElements;
}
public void setOrderByElements(List orderByElements) {
this.orderByElements = orderByElements;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isFirst() {
return first;
}
public void setFirst(boolean first) {
this.first = first;
}
@Override
public String toString() {
StringBuilder b = new StringBuilder();
b.append("KEEP (").append(name);
b.append(" ").append(first ? "FIRST" : "LAST").append(" ");
toStringOrderByElements(b);
b.append(")");
return b.toString();
}
private void toStringOrderByElements(StringBuilder b) {
if (orderByElements != null && !orderByElements.isEmpty()) {
b.append("ORDER BY ");
for (int i = 0; i < orderByElements.size(); i++) {
if (i > 0) {
b.append(", ");
}
b.append(orderByElements.get(i).toString());
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy