Fix sonars in policy-models
[policy/models.git] / models-pdp / src / main / java / org / onap / policy / models / pdp / persistence / provider / PdpFilterParameters.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.models.pdp.persistence.provider;
22
23 import java.time.Instant;
24 import java.util.Map;
25 import lombok.Builder;
26 import lombok.Getter;
27 import org.onap.policy.models.dao.PfFilterParametersIntfc;
28
29 @Getter
30 @Builder
31 public class PdpFilterParameters implements PfFilterParametersIntfc {
32     private String name;
33     private String version;
34     private Instant startTime;
35     private Instant endTime;
36
37     private int recordNum;
38     @Builder.Default
39     private String sortOrder = "DESC";
40
41     private String group;
42     private String subGroup;
43
44     // initialized lazily, if not set via the builder
45     private Map<String, Object> filterMap;
46
47     @Override
48     public Map<String, Object> getFilterMap() {
49         if (filterMap != null) {
50             return filterMap;
51
52         } else if (group == null) {
53             return null;
54
55         } else if (subGroup == null) {
56             filterMap = Map.of("pdpGroupName", group);
57             return filterMap;
58
59         } else {
60             filterMap = Map.of("pdpGroupName", group, "pdpSubGroupName", subGroup);
61             return filterMap;
62         }
63     }
64 }