Query implements Conditional<Query<T, Q>> { public Query<T, Q> where(String column, String termType, Object value) { if (value == null) { return this; } and(column, termType, value); return this; } Query(Q param); Q getParam(); Query<T, Q> setParam(Q param); Query<T, Q> excludes(String... columns); Query<T, Q> includes(String... columns); @SafeVarargs final Query<T, Q> select(StaticMethodReferenceColumn<B>... columns); @SafeVarargs final Query<T, Q> includes(StaticMethodReferenceColumn<B>... columns); @SafeVarargs final Query<T, Q> includes(MethodReferenceColumn<B>... columns); @SafeVarargs final Query<T, Q> excludes(StaticMethodReferenceColumn<B>... columns); @SafeVarargs final Query<T, Q> excludes(MethodReferenceColumn<B>... columns); Query<T, Q> orderByAsc(StaticMethodReferenceColumn<B> column); Query<T, Q> orderByDesc(StaticMethodReferenceColumn<B> column); Query<T, Q> orderByAsc(String column); Query<T, Q> orderByDesc(String column); Query<T, Q> doPaging(int pageIndex, int pageSize); Query<T, Q> noPaging(); Query<T, Q> forUpdate(); R execute(Function<Q, R> function); NestConditional<Query<T, Q>> nest(); @Override NestConditional<Query<T, Q>> orNest(); @Override Query<T, Q> and(); @Override Query<T, Q> or(); @Override Query<T, Q> accept(Term term); @Override Query<T, Q> and(String column, String termType, Object value); @Override Query<T, Q> or(String column, String termType, Object value); Query<T, Q> where(String column, String termType, Object value); @Override Accepter<Query<T, Q>, Object> getAccepter(); Query<T, Q> selectExcludes(String... columns); Query<T, Q> select(String... columns); static Query<R, P> of(P param); static Query<R, QueryParam> of();  }
@Test public void testWhere() { { Term term = Query.of().where(TestEntity::getId, "123").getParam().getTerms().get(0); Assert.assertEquals(term.getColumn(), "id"); Assert.assertEquals(term.getTermType(), "eq"); Assert.assertEquals(term.getValue(), "123"); } { assertSingleCondition(query -> query.like(TestEntity::getId, "123"), "like", "123"); assertSingleCondition(query -> query.like$(TestEntity::getId, "123"), "like", "123%"); assertSingleCondition(query -> query.$like(TestEntity::getId, "123"), "like", "%123"); assertSingleCondition(query -> query.$like$(TestEntity::getId, "123"), "like", "%123%"); } { assertSingleCondition(query -> query.in(TestEntity::getId, 1), "in", 1); assertSingleCondition(query -> query.in(TestEntity::getId, 1, 2, 3), "in", new Object[]{1, 2, 3}); assertSingleCondition(query -> query.in(TestEntity::getId, Arrays.asList(1, 2, 3)), "in", Arrays.asList(1, 2, 3)); } { assertSingleCondition(query -> query.gt(TestEntity::getId, 1), "gt", 1); assertSingleCondition(query -> query.gte(TestEntity::getId, 1), "gte",1); assertSingleCondition(query -> query.lt(TestEntity::getId,1), "lt", 1); assertSingleCondition(query -> query.lte(TestEntity::getId,1), "lte", 1); } }