2018-03-14 08:09:29 +01:00
|
|
|
package li.strolch.search;
|
|
|
|
|
|
|
|
import li.strolch.model.StrolchRootElement;
|
|
|
|
import li.strolch.utils.collections.DateRange;
|
|
|
|
|
|
|
|
public interface ExpressionBuilder {
|
|
|
|
|
|
|
|
Object extract(StrolchRootElement element);
|
|
|
|
|
|
|
|
default SearchExpression isEqualTo(Object right) {
|
2018-03-14 09:04:07 +01:00
|
|
|
return element -> PredicatesSupport.isEqualTo(right).matches(extract(element));
|
2018-03-14 08:09:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default SearchExpression isNotEqualTo(Object right) {
|
2018-03-14 09:04:07 +01:00
|
|
|
return element -> PredicatesSupport.isNotEqualTo(right).matches(extract(element));
|
2018-03-14 08:09:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default SearchExpression isEqualToIgnoreCase(Object right) {
|
2018-03-14 09:04:07 +01:00
|
|
|
return element -> PredicatesSupport.isEqualToIgnoreCase(right).matches(extract(element));
|
2018-03-14 08:09:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default SearchExpression isNotEqualToIgnoreCase(Object right) {
|
2018-03-14 09:04:07 +01:00
|
|
|
return element -> PredicatesSupport.isNotEqualToIgnoreCase(right).matches(extract(element));
|
2018-03-14 08:09:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default SearchExpression startsWith(Object right) {
|
2018-03-14 09:04:07 +01:00
|
|
|
return element -> PredicatesSupport.startsWith(right).matches(extract(element));
|
2018-03-14 08:09:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default SearchExpression startsWithIgnoreCase(Object right) {
|
2018-03-14 09:04:07 +01:00
|
|
|
return element -> PredicatesSupport.startsWithIgnoreCase(right).matches(extract(element));
|
2018-03-14 08:09:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default SearchExpression endsWith(Object right) {
|
2018-03-14 09:04:07 +01:00
|
|
|
return element -> PredicatesSupport.endsWith(right).matches(extract(element));
|
2018-03-14 08:09:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default SearchExpression endsWithIgnoreCase(Object right) {
|
2018-03-14 09:04:07 +01:00
|
|
|
return element -> PredicatesSupport.endsWithIgnoreCase(right).matches(extract(element));
|
2018-03-14 08:09:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default SearchExpression contains(Object right) {
|
2018-03-14 09:04:07 +01:00
|
|
|
return element -> PredicatesSupport.contains(right).matches(extract(element));
|
2018-03-14 08:09:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default SearchExpression containsIgnoreCase(Object right) {
|
2018-03-14 09:04:07 +01:00
|
|
|
return element -> PredicatesSupport.containsIgnoreCase(right).matches(extract(element));
|
2018-03-14 08:09:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default SearchExpression inRange(DateRange range) {
|
2018-03-14 09:04:07 +01:00
|
|
|
return element -> PredicatesSupport.inRange(range).matches(extract(element));
|
2018-03-14 08:09:29 +01:00
|
|
|
}
|
|
|
|
}
|