use of org.nutz.dao.FieldFilter in project nutz by nutzam.
the class NutDao method query.
public <T> List<T> query(final Class<T> classOfT, final Condition cnd, final Pager pager, String regex) {
if (regex == null)
return query(classOfT, cnd, pager);
FieldFilter ff = FieldFilter.create(classOfT, FieldMatcher.make(regex, null, false));
Molecule<List<T>> m = new Molecule<List<T>>() {
public void run() {
setObj(query(classOfT, cnd, pager));
}
};
return ff.run(m);
}
use of org.nutz.dao.FieldFilter in project nutz by nutzam.
the class NutDao method insert.
public <T> T insert(final T t, boolean ignoreNull, boolean ignoreZero, boolean ignoreBlankStr) {
Object obj = Lang.first(t);
Entity<?> en = getEntity(obj.getClass());
List<String> names = new ArrayList<String>();
for (MappingField mf : en.getMappingFields()) {
Object tmp = mf.getValue(obj);
if (ignoreNull && tmp == null) {
continue;
}
if (ignoreZero && (tmp == null || (tmp instanceof Number && ((Number) tmp).intValue() == 0))) {
continue;
}
if (ignoreBlankStr && (tmp instanceof CharSequence && Strings.isBlank((CharSequence) tmp)))
continue;
names.add(mf.getName());
}
FieldFilter ff = FieldFilter.create(obj.getClass(), "^(" + Strings.join("|", names.toArray()) + ")$");
Molecule<T> m = new Molecule<T>() {
public void run() {
insert(t);
setObj(t);
}
};
return ff.run(m);
}
use of org.nutz.dao.FieldFilter in project nutz by nutzam.
the class NutDao method query.
public <T> List<T> query(final Class<T> classOfT, final Condition cnd, final Pager pager, FieldMatcher matcher) {
if (matcher == null)
return query(classOfT, cnd, pager);
FieldFilter ff = FieldFilter.create(classOfT, matcher);
Molecule<List<T>> m = new Molecule<List<T>>() {
public void run() {
setObj(query(classOfT, cnd, pager));
}
};
return ff.run(m);
}
Aggregations