From dd21bce82da9617ff8f748f8567b0329aca07b83 Mon Sep 17 00:00:00 2001 From: Sotaro SUZUKI Date: Wed, 1 Oct 2014 15:32:06 +0900 Subject: add support condition oneOf / noneOf var-length parameterized IN(?, ?, ...), NOT IN(?, ?, ...) support --- src/main/java/com/iciql/QueryCondition.java | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/iciql/QueryCondition.java') 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 { return new QueryWhere(query); } + public QueryWhere oneOf(A... a) { + return oneOf(Utils.newArrayIterable(a)); + } + + public QueryWhere oneOf(Iterable i) { + query.addConditionToken(new Condition(x, i, CompareType.IN)); + return new QueryWhere(query); + } + + public QueryWhere noneOf(A... a) { + return noneOf(Utils.newArrayIterable(a)); + } + + public QueryWhere noneOf(Iterable i) { + query.addConditionToken(new Condition(x, i, CompareType.NOT_IN)); + return new QueryWhere(query); + } + public QueryWhere is(A y) { query.addConditionToken(new Condition(x, y, CompareType.EQUAL)); return new QueryWhere(query); @@ -52,12 +72,12 @@ public class QueryCondition { } public QueryWhere isNull() { - query.addConditionToken(new Condition(x, null, CompareType.IS_NULL)); + query.addConditionToken(new Condition(x, CompareType.IS_NULL)); return new QueryWhere(query); } public QueryWhere isNotNull() { - query.addConditionToken(new Condition(x, null, CompareType.IS_NOT_NULL)); + query.addConditionToken(new Condition(x, CompareType.IS_NOT_NULL)); return new QueryWhere(query); } -- cgit v1.2.3