mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-23 12:19:09 +00:00
#1426 - ENH: Add bitwiseNot expression ... e.g. bitwiseNot("flags", BwFlags.HAS_COLOUR)
This commit is contained in:
@@ -1031,6 +1031,20 @@ public interface ExpressionList<T> {
|
||||
*/
|
||||
ExpressionList<T> bitwiseAll(String propertyName, long flags);
|
||||
|
||||
/**
|
||||
* Add expression for the given bit flags to be NOT set.
|
||||
* <p>
|
||||
* <pre>{@code
|
||||
*
|
||||
* where().bitwiseNot("flags", BwFlags.HAS_COLOUR)
|
||||
*
|
||||
* }</pre>
|
||||
*
|
||||
* @param propertyName The property that holds the flags value
|
||||
* @param flags The flags we are looking for
|
||||
*/
|
||||
ExpressionList<T> bitwiseNot(String propertyName, long flags);
|
||||
|
||||
/**
|
||||
* Add bitwise AND expression of the given bit flags to compare with the match/mask.
|
||||
* <p>
|
||||
|
||||
@@ -711,6 +711,12 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> bitwiseNot(String propertyName, long flags) {
|
||||
add(expr.bitwiseAnd(propertyName, flags, 0));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> bitwiseAll(String propertyName, long flags) {
|
||||
add(expr.bitwiseAll(propertyName, flags));
|
||||
|
||||
@@ -554,6 +554,11 @@ class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expression
|
||||
return exprList.bitwiseAnd(propertyName, flags, match);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> bitwiseNot(String propertyName, long flags) {
|
||||
return exprList.bitwiseNot(propertyName, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> ge(String propertyName, Object value) {
|
||||
return exprList.ge(propertyName, value);
|
||||
|
||||
@@ -14,11 +14,24 @@ public class TestBitwiseExpressions extends BaseTestCase {
|
||||
public void where() {
|
||||
|
||||
setup();
|
||||
bitwiseNot();
|
||||
bitwiseAnd();
|
||||
bitwiseAny();
|
||||
bitwiseAll();
|
||||
}
|
||||
|
||||
private void bitwiseNot() {
|
||||
|
||||
List<BwBean> notColour = Ebean.find(BwBean.class)
|
||||
// HAS_COLOUR not set ...
|
||||
.where().bitwiseNot("flags", BwFlags.HAS_COLOUR)
|
||||
.findList();
|
||||
|
||||
assertThat(notColour).hasSize(2);
|
||||
assertThat(notColour.get(0).getName()).isEqualTo("Nothing");
|
||||
assertThat(notColour.get(1).getName()).isEqualTo("SizeOnly");
|
||||
}
|
||||
|
||||
private void bitwiseAnd() {
|
||||
|
||||
List<BwBean> list = Ebean.find(BwBean.class)
|
||||
|
||||
Reference in New Issue
Block a user