/hazelcast/src/main/java/com/hazelcast/query/EntryObject.java

https://bitbucket.org/gabral6_gmailcom/hazelcast · Java · 89 lines · 56 code · 18 blank · 15 comment · 0 complexity · e5c4389ada132097cbf8b7bb07261b3e MD5 · raw file

  1. /*
  2. * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
  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.hazelcast.query;
  17. public class EntryObject {
  18. PredicateBuilder qb;
  19. public EntryObject(PredicateBuilder qb) {
  20. this.qb = qb;
  21. }
  22. public EntryObject get(String property) {
  23. qb.exp = Predicates.get(property);
  24. return this;
  25. }
  26. public PredicateBuilder is(String property) {
  27. return addPredicate(Predicates.equal(Predicates.get(property), true));
  28. }
  29. public PredicateBuilder isNot(String property) {
  30. return addPredicate(Predicates.notEqual(Predicates.get(property), true));
  31. }
  32. public EntryObject key() {
  33. Expression expression = new EntryKeyObject();
  34. qb.exp = expression;
  35. return this;
  36. }
  37. public PredicateBuilder equal(Object value) {
  38. return addPredicate(Predicates.equal(qb.exp, value));
  39. }
  40. public PredicateBuilder notEqual(Object value) {
  41. return addPredicate(Predicates.notEqual(qb.exp, value));
  42. }
  43. public PredicateBuilder isNull() {
  44. return addPredicate(Predicates.equal(qb.exp, null));
  45. }
  46. public PredicateBuilder isNotNull() {
  47. return addPredicate(Predicates.notEqual(qb.exp, null));
  48. }
  49. public PredicateBuilder greaterThan(Comparable value) {
  50. return addPredicate(Predicates.greaterThan(qb.exp, value));
  51. }
  52. public PredicateBuilder greaterEqual(Comparable value) {
  53. return addPredicate(Predicates.greaterEqual(qb.exp, value));
  54. }
  55. public PredicateBuilder lessThan(Comparable value) {
  56. return addPredicate(Predicates.lessThan(qb.exp, value));
  57. }
  58. public PredicateBuilder lessEqual(Comparable value) {
  59. return addPredicate(Predicates.lessEqual(qb.exp, value));
  60. }
  61. public PredicateBuilder between(Comparable from, Comparable to) {
  62. return addPredicate(Predicates.between(qb.exp, from, to));
  63. }
  64. public PredicateBuilder in(Comparable... values) {
  65. return addPredicate(Predicates.in(qb.exp, values));
  66. }
  67. private PredicateBuilder addPredicate(Predicate predicate) {
  68. qb.lsPredicates.add(predicate);
  69. return qb;
  70. }
  71. }