org.onetwo.common.db.builder.SingleFieldWhereCauseBuilderField Maven / Gradle / Ivy
The newest version!
package org.onetwo.common.db.builder;
import java.util.Collection;
import java.util.Date;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang3.ArrayUtils;
import org.onetwo.common.db.builder.SingleFieldWhereCauseBuilderField.SingleFieldWhereCauseBuilderFieldEnder;
import org.onetwo.common.db.sqlext.ExtQueryUtils;
import org.onetwo.common.db.sqlext.QueryDSLOps;
import org.onetwo.common.utils.CUtils;
import org.onetwo.common.utils.StringUtils;
@SuppressWarnings("unchecked")
public class SingleFieldWhereCauseBuilderField extends WhereCauseBuilderField> {
private String field;
private QueryDSLOps[] ops;
private Object values;
private SingleFieldWhereCauseBuilderFieldEnder ender;
public SingleFieldWhereCauseBuilderField(WhereCauseBuilder squery, String field) {
super(squery);
this.field = field;
this.ender = new SingleFieldWhereCauseBuilderFieldEnder<>(this);
}
public SingleFieldWhereCauseBuilderField when(Supplier predicate) {
this.whenPredicate = predicate;
return this;
}
/***
* like '%value'
* @author weishao zeng
* @param values
* @return
*/
public SingleFieldWhereCauseBuilderFieldEnder prelike(String... values) {
Object[] strings = Stream.of(values)
.map(val -> StringUtils.appendStartWith(val, "%"))
.collect(Collectors.toList())
.toArray();
setOpValues(QueryDSLOps.LIKE, strings);
return ender();
// this.op = FieldOP.like;
// this.values = Stream.of(values)
// .map(val -> StringUtils.appendStartWith(val, "%"))
// .collect(Collectors.toList())
// .toArray(new String[0]);
// this.queryBuilder.addField(this);
// return queryBuilder;
}
/***
* like 'value%'
* @author weishao zeng
* @param values
* @return
*/
public SingleFieldWhereCauseBuilderFieldEnder postlike(String... values) {
Object[] strings = Stream.of(values)
.map(val -> StringUtils.appendEndWith(val, "%"))
.collect(Collectors.toList())
.toArray();
setOpValues(QueryDSLOps.LIKE, strings);
return ender();
}
public SingleFieldWhereCauseBuilderFieldEnder notLike(String... values) {
setOpValues(QueryDSLOps.NOT_LIKE, (Object[])values);
return ender();
}
public SingleFieldWhereCauseBuilderFieldEnder like(String... values) {
setOpValues(QueryDSLOps.LIKE, (Object[])values);
return ender();
}
/***
* 等于
* @param values
* @return
*/
public SingleFieldWhereCauseBuilderFieldEnder equalTo(T... values) {
setOpValues(QueryDSLOps.EQ, values);
return ender();
}
public SingleFieldWhereCauseBuilderFieldEnder value(QueryDSLOps sqlOp, Supplier
© 2015 - 2025 Weber Informatics LLC | Privacy Policy