
br.com.objectos.sql.AbstractSimpleSelectWhere2 Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2014-2015 Objectos, Fábrica de Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package br.com.objectos.sql;
import br.com.objectos.db.Condition;
import br.com.objectos.db.Dialect;
import br.com.objectos.db.IntTypeColumn;
import br.com.objectos.db.LocalDateTypeColumn;
import br.com.objectos.db.Order;
import br.com.objectos.db.Orderable;
import br.com.objectos.db.ParameterBinder;
import br.com.objectos.db.SelectBuilder;
import br.com.objectos.db.Selectable;
import br.com.objectos.db.StringTypeColumn;
/**
* @author [email protected] (Marcio Endo)
*/
abstract class AbstractSimpleSelectWhere2
extends SelectNode>
implements
SimpleSelectWhere> {
private Condition condition;
public AbstractSimpleSelectWhere2(SelectNode> previous) {
super(previous);
}
@Override
public SimpleSelectWhere2Int and(X column) {
setCondition();
return new SimpleSelectWhere2Int<>(this, Keyword.AND, column);
}
@Override
public SimpleSelectWhere2LocalDate and(X column) {
setCondition();
return new SimpleSelectWhere2LocalDate<>(this, Keyword.AND, column);
}
@Override
public SimpleSelectWhere2String and(X column) {
setCondition();
return new SimpleSelectWhere2String<>(this, Keyword.AND, column);
}
@Override
public SimpleSelectQuery2 compile(Dialect dialect) {
setCondition();
return new SimpleSelectQuery2<>(dialect, this);
}
@Override
public SimpleSelectOrderBy2 orderBy(Orderable o1) {
return orderBy(o1.asc());
}
@Override
public SimpleSelectOrderBy2 orderBy(Order o1) {
return orderBy0(o1);
}
@Override
ParameterBinder bind0(ParameterBinder binder) {
if (condition != null) {
condition.bind(binder);
}
return binder;
}
abstract Condition condition();
@Override
SelectBuilder write0(SelectBuilder sql) {
return condition != null ? sql.where(condition) : sql;
}
private SimpleSelectOrderBy2 orderBy0(Order... columns) {
setCondition();
return new SimpleSelectOrderBy2<>(this, columns);
}
private void setCondition() {
condition = condition();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy