Commit e710e47b authored by Matija Obreza's avatar Matija Obreza

Added NumberFilter#between and DateFilter#between operation

parent cbc79dcd
......@@ -43,6 +43,11 @@ public class DateFilter {
// <
public Date lt;
/**
* Between is array of two values [a, b]
*/
public Date[] between;
public Predicate buildQuery(final TemporalExpression<Date> date) {
final BooleanBuilder and = new BooleanBuilder();
if (ge != null) {
......@@ -57,6 +62,9 @@ public class DateFilter {
if (lt != null) {
and.and(date.lt(lt));
}
if (between != null && between.length == 2) {
and.and(date.between(between[0], between[1]));
}
return and;
}
......@@ -75,6 +83,9 @@ public class DateFilter {
if (lt != null) {
str.append(" date < ").append(lt).append(" ");
}
if (between != null) {
str.append(" date between ").append(between[0]).append(" and ").append(between[1]);
}
return str.toString().replaceAll("\\s{2,}", " ");
}
......
......@@ -47,6 +47,11 @@ public class NumberFilter<T extends Number & Comparable<?>> {
*/
public T le;
/**
* Between is array of two values [a, b]
*/
public T[] between;
public BooleanBuilder buildQuery(final NumberPath<T> val) {
final BooleanBuilder and = new BooleanBuilder();
if (eq != null) {
......@@ -64,8 +69,8 @@ public class NumberFilter<T extends Number & Comparable<?>> {
if (le != null) {
and.and(val.loe(le));
}
if (gt != null) {
and.and(val.gt(gt));
if (between != null && between.length == 2) {
and.and(val.between(between[0], between[1]));
}
return and;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment