#2768 - ENH: Add eqIfPresent() - a helper expression for fluid style when some EQ are optional

This commit is contained in:
Rob Bygrave committed 2022-08-01 16:36:09 +12:00
1 parent f930471beb
commit 7474430a63
6 files changed
+116 -3

No files matched your search

@@ -798,6 +798,11 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
return add(expr.eq(propertyName, value));
}
@Override
public ExpressionList<T> eqIfPresent(String propertyName, @Nullable Object value) {
return value == null ? this : add(expr.eq(propertyName, value));
}
@Override
public ExpressionList<T> eqOrNull(String propertyName, Object value) {
return add(expr.eqOrNull(propertyName, value));
@@ -309,6 +309,11 @@ final class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expr
return exprList.eq(propertyName, value);
}
@Override
public ExpressionList<T> eqIfPresent(String propertyName, @Nullable Object value) {
return value == null ? this : exprList.eq(propertyName, value);
}
@Override
public ExpressionList<T> eqOrNull(String propertyName, Object value) {
return exprList.eqOrNull(propertyName, value);