net.sf.jsqlparser.statement.select.SubJoin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsqlparser Show documentation
Show all versions of jsqlparser Show documentation
JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes.
The generated hierarchy can be navigated using the Visitor Pattern.
/*-
* #%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.statement.select;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.sf.jsqlparser.expression.Alias;
public class SubJoin implements FromItem {
private FromItem left;
private Alias alias;
private Pivot pivot;
private UnPivot unpivot;
private List joinList;
@Override
public void accept(FromItemVisitor fromItemVisitor) {
fromItemVisitor.visit(this);
}
public FromItem getLeft() {
return left;
}
public SubJoin left(FromItem l) {
setLeft(l);
return this;
}
public void setLeft(FromItem l) {
left = l;
}
public List getJoinList() {
return joinList;
}
public void setJoinList(List joinList) {
this.joinList = joinList;
}
@Override
public Pivot getPivot() {
return pivot;
}
@Override
public void setPivot(Pivot pivot) {
this.pivot = pivot;
}
@Override
public UnPivot getUnPivot() {
return this.unpivot;
}
@Override
public void setUnPivot(UnPivot unpivot) {
this.unpivot = unpivot;
}
@Override
public Alias getAlias() {
return alias;
}
@Override
public void setAlias(Alias alias) {
this.alias = alias;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("(").append(left);
for (Join j : joinList) {
if (j.isSimple()) {
sb.append(", ").append(j);
} else {
sb.append(" ").append(j);
}
}
sb.append(")").append((alias != null) ? (" " + alias.toString()) : "")
.append((pivot != null) ? " " + pivot : "").append((unpivot != null) ? " " + unpivot : "");
return sb.toString();
}
@Override
public SubJoin withAlias(Alias alias) {
return (SubJoin) FromItem.super.withAlias(alias);
}
@Override
public SubJoin withPivot(Pivot pivot) {
return (SubJoin) FromItem.super.withPivot(pivot);
}
@Override
public SubJoin withUnPivot(UnPivot unpivot) {
return (SubJoin) FromItem.super.withUnPivot(unpivot);
}
public SubJoin withJoinList(List joinList) {
this.setJoinList(joinList);
return this;
}
public SubJoin addJoinList(Join... joinList) {
List collection = Optional.ofNullable(getJoinList()).orElseGet(ArrayList::new);
Collections.addAll(collection, joinList);
return this.withJoinList(collection);
}
public SubJoin addJoinList(Collection extends Join> joinList) {
List collection = Optional.ofNullable(getJoinList()).orElseGet(ArrayList::new);
collection.addAll(joinList);
return this.withJoinList(collection);
}
public E getLeft(Class type) {
return type.cast(getLeft());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy