You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

QueryBetween.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2011 James Moger.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.iciql;
  17. /**
  18. * This class represents a "between y and z" condition.
  19. *
  20. * @param <T> the return type of the query
  21. * @param <A> the incomplete condition data type
  22. */
  23. public class QueryBetween<T, A> {
  24. private Query<T> query;
  25. private A x;
  26. private A y;
  27. /**
  28. * Construct a between condition.
  29. *
  30. * @param query the query
  31. * @param x the alias
  32. * @param y the lower bound of the between condition
  33. */
  34. public QueryBetween(Query<T> query, A x, A y) {
  35. this.query = query;
  36. this.x = x;
  37. this.y = y;
  38. }
  39. /**
  40. * Set the upper bound of the between condition.
  41. *
  42. * @param z the upper bound of the between condition
  43. * @return the query
  44. */
  45. public QueryWhere<T> and(A z) {
  46. query.addConditionToken(new Condition<A>(x, y, z, CompareType.BETWEEN));
  47. return new QueryWhere<T>(query);
  48. }
  49. }