NEW: ExpressionList has clear() method

This commit is contained in:
Roland Praml
2023-01-23 11:33:29 +01:00
parent 09a831f2d6
commit 371f50fb4d
4 changed files with 23 additions and 0 deletions
@@ -1730,4 +1730,8 @@ public interface ExpressionList<T> {
*/
ExpressionList<T> endNot();
/**
* Clears the current expression list.
*/
ExpressionList<T> clear();
}
@@ -1268,4 +1268,10 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
}
return null;
}
@Override
public ExpressionList<T> clear() {
list.clear();
return this;
}
}
@@ -1068,4 +1068,9 @@ final class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expr
}
return null;
}
@Override
public ExpressionList<T> clear() {
return exprList.clear();
}
}
@@ -99,6 +99,14 @@ public class DefaultExpressionListTest extends BaseExpressionTest {
.isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isFalse();
}
@Test
public void isSameWithClear() {
DefaultExpressionList<?> exp1 = spi(exp().eq("a", 10).eq("b", 20).clear().eq("c", 30));
DefaultExpressionList<?> exp2 = spi(exp().eq("c", 30));
same(exp1, exp2);
assertThat(exp1.isSameByBind(exp2)).isTrue();
}
@SuppressWarnings("unchecked")
@Test
void copy() {