55a490f700dbaecc635f33021c72d21d503556e0
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / search / filters / entity / SearchFilter.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21 package org.onap.aai.sparky.search.filters.entity;
22
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.List;
26
27 /**
28  * A base entity to contain the details of the filter id and values from the FE to the BE for the
29  * purpose of driving DAL calls into ElasticSearch, Search Abstraction Service, or as a utility
30  * object within the query builders.
31  * 
32  * The class has unique identifier for the filter id, and then 1 or more filter values. The value
33  * list has been introduced to help us with a multi-select use case that will need to be supported
34  * eventually.
35  */
36 public class SearchFilter {
37
38   private String filterId;
39   private List<String> values;
40
41   public SearchFilter() {
42     values = new ArrayList<String>();
43   }
44   
45   public SearchFilter(String filterId) {
46     this();
47     this.filterId = filterId;
48   }
49   
50   public SearchFilter(String filterId, String... values) {
51     this();
52     this.filterId = filterId;
53     this.values.addAll(Arrays.asList(values));
54   }
55   
56   public String getFilterId() {
57     return filterId;
58   }
59
60   public void setFilterId(String filterId) {
61     this.filterId = filterId;
62   }
63
64   public List<String> getValues() {
65     return values;
66   }
67
68   public void setValues(List<String> values) {
69     this.values = values;
70   }
71
72   public void addValue(String v) {
73     if (!values.contains(v)) {
74       values.add(v);
75     }
76
77   }
78
79   @Override
80   public String toString() {
81     return "SearchFilter [filterId=" + filterId + ", values=" + values + "]";
82   }
83
84 }