diff options
author | Sotaro SUZUKI <sotaro.suzuki@architector.jp> | 2014-10-01 15:32:06 +0900 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-10-06 10:08:50 -0400 |
commit | dd21bce82da9617ff8f748f8567b0329aca07b83 (patch) | |
tree | 730a2b85b54537a016219b9a08f4d16fb82897e1 /src/main/java/com/iciql/QueryCondition.java | |
parent | 06c1374cfc17bdad621f6ad5154f4de08905da99 (diff) | |
download | iciql-dd21bce82da9617ff8f748f8567b0329aca07b83.tar.gz iciql-dd21bce82da9617ff8f748f8567b0329aca07b83.zip |
add support condition oneOf / noneOf
var-length parameterized IN(?, ?, ...), NOT IN(?, ?, ...) support
Diffstat (limited to 'src/main/java/com/iciql/QueryCondition.java')
-rw-r--r-- | src/main/java/com/iciql/QueryCondition.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/main/java/com/iciql/QueryCondition.java b/src/main/java/com/iciql/QueryCondition.java index 9613b1b..cef95c1 100644 --- a/src/main/java/com/iciql/QueryCondition.java +++ b/src/main/java/com/iciql/QueryCondition.java @@ -17,6 +17,8 @@ package com.iciql; +import com.iciql.util.Utils; + /** * This class represents a query with an incomplete condition. * @@ -41,6 +43,24 @@ public class QueryCondition<T, A> { return new QueryWhere<T>(query); } + public QueryWhere<T> oneOf(A... a) { + return oneOf(Utils.newArrayIterable(a)); + } + + public QueryWhere<T> oneOf(Iterable<A> i) { + query.addConditionToken(new Condition<A>(x, i, CompareType.IN)); + return new QueryWhere<T>(query); + } + + public QueryWhere<T> noneOf(A... a) { + return noneOf(Utils.newArrayIterable(a)); + } + + public QueryWhere<T> noneOf(Iterable<A> i) { + query.addConditionToken(new Condition<A>(x, i, CompareType.NOT_IN)); + return new QueryWhere<T>(query); + } + public QueryWhere<T> is(A y) { query.addConditionToken(new Condition<A>(x, y, CompareType.EQUAL)); return new QueryWhere<T>(query); @@ -52,12 +72,12 @@ public class QueryCondition<T, A> { } public QueryWhere<T> isNull() { - query.addConditionToken(new Condition<A>(x, null, CompareType.IS_NULL)); + query.addConditionToken(new Condition<A>(x, CompareType.IS_NULL)); return new QueryWhere<T>(query); } public QueryWhere<T> isNotNull() { - query.addConditionToken(new Condition<A>(x, null, CompareType.IS_NOT_NULL)); + query.addConditionToken(new Condition<A>(x, CompareType.IS_NOT_NULL)); return new QueryWhere<T>(query); } |