/** * @param criterion another criterion to be appended with OR. If null, this Criterion will be returned unmodified. * @return a criterion equivalent to (this OR criterion) */ public Criterion or(Criterion criterion) { if (criterion == null) { return this; } return or(this, criterion); }
@Override public Criterion or(Criterion criterion) { Criterion toReturn = checkOperatorAndAppendCriterions(Operator.or, criterion); if (toReturn == null) { return super.or(criterion); } return toReturn; }
/** * @return a {@link Criterion} that the property is null or the empty string '' */ public Criterion isEmpty() { return isNull().or(eq("")); }
@Override public void run() { Criterion.or(null, TestModel.ID.eq(1)); } }, IllegalArgumentException.class);
public void testInstanceVsStaticConjunction() { Criterion c1 = TestModel.FIRST_NAME.eq("Sam"); Criterion c2 = TestModel.LAST_NAME.eq("Bosley"); Criterion c3 = TestModel.LUCKY_NUMBER.eq(7); Criterion c = c1.and(c2); Criterion cand = c.and(c3); assertNotSame(c, cand); // Tests immutability of conjunction criterions when appending with the same operator assertEquals(Criterion.and(c1, c2, c3), c1.and(c2).and(c3)); assertEquals(Criterion.and(Arrays.asList(c1, c2, c3)), c1.and(c2).and(c3)); assertEquals(Criterion.or(c1, c2, c3), c1.or(c2).or(c3)); assertEquals(Criterion.or(Arrays.asList(c1, c2, c3)), c1.or(c2).or(c3)); assertEquals(Criterion.or(Criterion.and(c1, c2), c3), c1.and(c2).or(c3)); assertEquals(Criterion.and(Criterion.or(c1, c2), c3), c1.or(c2).and(c3)); assertEquals(Criterion.and(c1, Criterion.or(c2, c3)), c1.and(c2.or(c3))); assertEquals(Criterion.or(c1, Criterion.and(c2, c3)), c1.or(c2.and(c3))); }
/** * @param criterion another criterion to be appended with OR. If null, this Criterion will be returned unmodified. * @return a criterion equivalent to (this OR criterion) */ public Criterion or(Criterion criterion) { if (criterion == null) { return this; } return or(this, criterion); }
public Query getOrderedTasksWithTags() { Function<Long> unixNow = Function.multiply(1000, Function.functionWithArguments("strftime", "%s", "now")); Function<Long> sinceCompletion = Function.subtract(unixNow, Task.COMPLETION_DATE); return getTasksWithTagsQuery(Task.COMPLETION_DATE.eq(0) .or(sinceCompletion.lt(60000 * 5))) .orderBy(Function.caseWhen(Task.DUE_DATE.neq(0)).desc(), Task.DUE_DATE.asc()); }
@Override public Criterion or(Criterion criterion) { Criterion toReturn = checkOperatorAndAppendCriterions(Operator.or, criterion); if (toReturn == null) { return super.or(criterion); } return toReturn; }
public void testInCriterion() { List<String> expectedNames = Arrays.asList("bigBird", "cookieMonster"); Query query = Query.select().where(Employee.NAME.in("bigBird", "cookieMonster")).orderBy(Employee.NAME.asc()); testInQuery(expectedNames, query); query = Query.select().where(Employee.NAME.notIn("bigBird", "cookieMonster")).orderBy(Employee.NAME.asc()); testInQuery(Arrays.asList("bert", "elmo", "ernie", "oscar"), query); List<String> list = Arrays.asList("bigBird", "cookieMonster"); query = Query.select().where(Employee.NAME.in(list)).orderBy(Employee.NAME.asc()); testInQuery(expectedNames, query); // Test off-by-one error that used to occur when the in criterion wasn't the last criterion in the list query = Query.select().where(Employee.NAME.in(list).or(Field.field("1").neq(1))).orderBy(Employee.NAME.asc()); testInQuery(expectedNames, query); }
/** * @return a {@link Criterion} that the property is null or the empty string '' */ public Criterion isEmpty() { return isNull().or(eq("")); }