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;
27 public class RangeQueryBuilder extends QueryBuilder {
29 private Object gtValue = null;
30 private Object gteValue = null;
31 private Float boost = 2.0f;
32 private Object ltValue = null;
33 private Object lteValue = null;
36 public RangeQueryBuilder(String key) {
42 private void setQuery() {
43 JSONObject r = new JSONObject();
44 JSONObject k = new JSONObject();
45 if (this.gteValue != null) {
46 k.put("gte", this.gteValue);
47 } else if (this.gtValue != null) {
48 k.put("gt", this.gtValue);
50 if (this.lteValue != null) {
51 k.put("lte", this.lteValue);
52 } else if (this.ltValue != null) {
53 k.put("lt", this.ltValue);
55 if (this.boost != null) {
56 k.put("boost", this.boost);
60 this.setQuery("range", r);
64 public RangeQueryBuilder lte(Object compare) {
65 this.lteValue = compare;
71 public RangeQueryBuilder lt(Object compare) {
73 this.ltValue = compare;
78 public RangeQueryBuilder gte(Object compare) {
79 this.gteValue = compare;
85 public RangeQueryBuilder gt(Object compare) {
87 this.gtValue = compare;