com.reinaldoarrosi.android.querybuilder.sqlite.criteria.BetweenCriteria 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.criteria;
import java.util.ArrayList;
import java.util.List;
import com.reinaldoarrosi.android.querybuilder.sqlite.projection.AliasedProjection;
import com.reinaldoarrosi.android.querybuilder.sqlite.projection.Projection;
public class BetweenCriteria extends Criteria {
private Projection projection;
private Object valueStart;
private Object valueEnd;
public BetweenCriteria(Projection projection, Object valueStart, Object valueEnd) {
this.projection = projection;
this.valueStart = valueStart;
this.valueEnd = valueEnd;
if(this.projection instanceof AliasedProjection)
this.projection = ((AliasedProjection)this.projection).removeAlias();
}
@Override
public String build() {
StringBuilder sb = new StringBuilder();
if(projection != null)
sb.append(projection.build());
sb.append(" BETWEEN ");
sb.append((valueStart != null ? "?" : "NULL"));
sb.append(" AND ");
sb.append((valueEnd != null ? "?" : "NULL"));
return sb.toString();
}
@Override
public List