2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
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=========================================================
21 package org.onap.aai.sa.searchdbabstraction.searchapi;
23 import com.fasterxml.jackson.annotation.JsonProperty;
26 * This class represents the ranges specification in an date_range statement.
28 * The expected JSON structure for a ranges is as follows:
48 * "from": <from-date>,
55 public class DateRange {
58 private String fromDate;
61 private String toDate;
63 public String getFromDate() {
67 public void setFromDate(String fromDate) {
68 this.fromDate = fromDate;
71 public String getToDate() {
75 public void setToDate(String toDate) {
79 public String toElasticSearch() {
80 StringBuilder sb = new StringBuilder();
84 if (fromDate != null) {
85 sb.append("\"from\": \"");
86 sb.append(fromDate.toString());
91 if (fromDate != null) {
92 sb.append(", \"to\": \"");
93 sb.append(toDate.toString());
96 sb.append("\"to\": \"");
97 sb.append(toDate.toString());
104 return sb.toString();
107 public String toString() {
108 return "{from: " + fromDate + ", to: " + toDate + "}";