Move PAP database provider to spring boot default
[policy/pap.git] / main / src / main / java / org / onap / policy / pap / main / parameters / PdpModifyRequestMapParams.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP PAP
4  * ================================================================================
5  * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
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
22 package org.onap.policy.pap.main.parameters;
23
24 import lombok.Builder;
25 import lombok.Getter;
26 import org.onap.policy.common.endpoints.listeners.RequestIdDispatcher;
27 import org.onap.policy.models.pdp.concepts.PdpMessage;
28 import org.onap.policy.models.pdp.concepts.PdpStatus;
29 import org.onap.policy.pap.main.comm.Publisher;
30 import org.onap.policy.pap.main.comm.TimerManager;
31
32
33 /**
34  * Parameters needed to create a {@link PdpModifyRequestMapParams}.
35  */
36 @Getter
37 @Builder
38 public class PdpModifyRequestMapParams {
39     private long maxPdpAgeMs;
40     private Publisher<PdpMessage> pdpPublisher;
41     private RequestIdDispatcher<PdpStatus> responseDispatcher;
42     private Object modifyLock;
43     private PdpParameters params;
44     private TimerManager updateTimers;
45     private TimerManager stateChangeTimers;
46     private boolean savePdpStatistics;
47
48     /**
49      * Validates the parameters.
50      */
51     public void validate() {
52         if (maxPdpAgeMs < 1) {
53             throw new IllegalArgumentException("maxPdpAgeMs must be >= 1");
54         }
55
56         if (pdpPublisher == null) {
57             throw new IllegalArgumentException("missing publisher");
58         }
59
60         if (responseDispatcher == null) {
61             throw new IllegalArgumentException("missing responseDispatcher");
62         }
63
64         if (modifyLock == null) {
65             throw new IllegalArgumentException("missing modifyLock");
66         }
67
68         if (params == null) {
69             throw new IllegalArgumentException("missing PDP parameters");
70         }
71
72         if (updateTimers == null) {
73             throw new IllegalArgumentException("missing updateTimers");
74         }
75
76         if (stateChangeTimers == null) {
77             throw new IllegalArgumentException("missing stateChangeTimers");
78         }
79     }
80 }