2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.common.database.queries;
24 import org.json.JSONObject;
26 public class RangeQueryBuilder extends QueryBuilder {
28 private Object gtValue = null;
29 private Object gteValue = null;
30 private Float boost = 2.0f;
31 private Object ltValue = null;
32 private Object lteValue = null;
35 public RangeQueryBuilder(String key) {
41 private void setQuery() {
42 JSONObject r = new JSONObject();
43 JSONObject k = new JSONObject();
44 if (this.gteValue != null) {
45 k.put("gte", this.gteValue);
46 } else if (this.gtValue != null) {
47 k.put("gt", this.gtValue);
49 if (this.lteValue != null) {
50 k.put("lte", this.lteValue);
51 } else if (this.ltValue != null) {
52 k.put("lt", this.ltValue);
54 if (this.boost != null) {
55 k.put("boost", this.boost);
59 this.setQuery("range", r);
63 public RangeQueryBuilder lte(Object compare) {
64 this.lteValue = compare;
70 public RangeQueryBuilder lt(Object compare) {
72 this.ltValue = compare;
77 public RangeQueryBuilder gte(Object compare) {
78 this.gteValue = compare;
84 public RangeQueryBuilder gt(Object compare) {
86 this.gtValue = compare;