Adding interfaces in documentation
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / search / filters / entity / SearchFilter.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
8  * ============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25 package org.onap.aai.sparky.search.filters.entity;
26
27 import java.util.ArrayList;
28 import java.util.Arrays;
29 import java.util.List;
30
31 /**
32  * A base entity to contain the details of the filter id and values from the FE to the BE for the
33  * purpose of driving DAL calls into ElasticSearch, Search Abstraction Service, or as a utility
34  * object within the query builders.
35  * 
36  * The class has unique identifier for the filter id, and then 1 or more filter values. The value
37  * list has been introduced to help us with a multi-select use case that will need to be supported
38  * eventually.
39  */
40 public class SearchFilter {
41
42   private String filterId;
43   private List<String> values;
44
45   public SearchFilter() {
46     values = new ArrayList<String>();
47   }
48   
49   public SearchFilter(String filterId) {
50     this();
51     this.filterId = filterId;
52   }
53   
54   public SearchFilter(String filterId, String... values) {
55     this();
56     this.filterId = filterId;
57     this.values.addAll(Arrays.asList(values));
58   }
59   
60   public String getFilterId() {
61     return filterId;
62   }
63
64   public void setFilterId(String filterId) {
65     this.filterId = filterId;
66   }
67
68   public List<String> getValues() {
69     return values;
70   }
71
72   public void setValues(List<String> values) {
73     this.values = values;
74   }
75
76   public void addValue(String v) {
77     if (!values.contains(v)) {
78       values.add(v);
79     }
80
81   }
82
83   @Override
84   public String toString() {
85     return "SearchFilter [filterId=" + filterId + ", values=" + values + "]";
86   }
87
88 }