PageRenderTime 29ms CodeModel.GetById 18ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/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
17package com.hazelcast.query;
18
19public class EntryObject {
20    PredicateBuilder qb;
21
22    public EntryObject(PredicateBuilder qb) {
23        this.qb = qb;
24    }
25
26    public EntryObject get(String property) {
27        qb.exp = Predicates.get(property);
28        return this;
29    }
30
31    public PredicateBuilder is(String property) {
32        return addPredicate(Predicates.equal(Predicates.get(property), true));
33    }
34
35    public PredicateBuilder isNot(String property) {
36        return addPredicate(Predicates.notEqual(Predicates.get(property), true));
37    }
38
39    public EntryObject key() {
40        Expression expression = new EntryKeyObject();
41        qb.exp = expression;
42        return this;
43    }
44
45    public PredicateBuilder equal(Object value) {
46        return addPredicate(Predicates.equal(qb.exp, value));
47    }
48
49    public PredicateBuilder notEqual(Object value) {
50        return addPredicate(Predicates.notEqual(qb.exp, value));
51    }
52
53    public PredicateBuilder isNull() {
54        return addPredicate(Predicates.equal(qb.exp, null));
55    }
56
57    public PredicateBuilder isNotNull() {
58        return addPredicate(Predicates.notEqual(qb.exp, null));
59    }
60
61    public PredicateBuilder greaterThan(Comparable value) {
62        return addPredicate(Predicates.greaterThan(qb.exp, value));
63    }
64
65    public PredicateBuilder greaterEqual(Comparable value) {
66        return addPredicate(Predicates.greaterEqual(qb.exp, value));
67    }
68
69    public PredicateBuilder lessThan(Comparable value) {
70        return addPredicate(Predicates.lessThan(qb.exp, value));
71    }
72
73    public PredicateBuilder lessEqual(Comparable value) {
74        return addPredicate(Predicates.lessEqual(qb.exp, value));
75    }
76
77    public PredicateBuilder between(Comparable from, Comparable to) {
78        return addPredicate(Predicates.between(qb.exp, from, to));
79    }
80
81    public PredicateBuilder in(Comparable... values) {
82        return addPredicate(Predicates.in(qb.exp, values));
83    }
84
85    private PredicateBuilder addPredicate(Predicate predicate) {
86        qb.lsPredicates.add(predicate);
87        return qb;
88    }
89}