com.reinaldoarrosi.android.querybuilder.sqlite.from.JoinFrom Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of query-builder Show documentation
Show all versions of query-builder Show documentation
Fluent Android library to build SQLite select statements
The newest version!
package com.reinaldoarrosi.android.querybuilder.sqlite.from;
import java.util.ArrayList;
import java.util.List;
import com.reinaldoarrosi.android.querybuilder.sqlite.criteria.Criteria;
import com.reinaldoarrosi.android.querybuilder.sqlite.projection.Projection;
public class JoinFrom extends From {
private From left;
private From right;
private String joinType;
private Criteria criteria;
public JoinFrom(From left, From right, String joinType, Criteria criteria) {
this.left = left;
this.right = right;
this.joinType = joinType;
this.criteria = criteria;
}
public JoinFrom onOr(String leftColumn, String rightColumn) {
return onOr(Criteria.equals(Projection.column(leftColumn), Projection.column(rightColumn)));
}
public JoinFrom onAnd(String leftColumn, String rightColumn) {
return onAnd(Criteria.equals(Projection.column(leftColumn), Projection.column(rightColumn)));
}
public JoinFrom onAnd(Criteria criteria) {
this.criteria = (this.criteria != null ? this.criteria.and(criteria) : criteria);
return this;
}
public JoinFrom onOr(Criteria criteria) {
this.criteria = (this.criteria != null ? this.criteria.or(criteria) : criteria);
return this;
}
@Override
public String build() {
String leftSide = (left != null ? left.build() : "");
String rightSide = (right != null ? right.build() : "");
String joinCriteria = (criteria != null ? criteria.build() : "");
return "(" + leftSide + " " + joinType + " " + rightSide + " ON " + joinCriteria + ")";
}
@Override
public List