Generate notifications when policies change
[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 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.pap.main.parameters;
22
23 import lombok.Getter;
24 import org.onap.policy.common.endpoints.listeners.RequestIdDispatcher;
25 import org.onap.policy.models.pdp.concepts.PdpMessage;
26 import org.onap.policy.models.pdp.concepts.PdpStatus;
27 import org.onap.policy.pap.main.PolicyModelsProviderFactoryWrapper;
28 import org.onap.policy.pap.main.comm.Publisher;
29 import org.onap.policy.pap.main.comm.TimerManager;
30 import org.onap.policy.pap.main.notification.PolicyNotifier;
31
32
33 /**
34  * Parameters needed to create a {@link PdpModifyRequestMapParams}.
35  */
36 @Getter
37 public class PdpModifyRequestMapParams {
38     private Publisher<PdpMessage> pdpPublisher;
39     private RequestIdDispatcher<PdpStatus> responseDispatcher;
40     private Object modifyLock;
41     private PdpParameters params;
42     private TimerManager updateTimers;
43     private TimerManager stateChangeTimers;
44     private PolicyModelsProviderFactoryWrapper daoFactory;
45     private PolicyNotifier policyNotifier;
46
47     public PdpModifyRequestMapParams setParams(PdpParameters params) {
48         this.params = params;
49         return this;
50     }
51
52     public PdpModifyRequestMapParams setUpdateTimers(TimerManager updateTimers) {
53         this.updateTimers = updateTimers;
54         return this;
55     }
56
57     public PdpModifyRequestMapParams setStateChangeTimers(TimerManager stateChangeTimers) {
58         this.stateChangeTimers = stateChangeTimers;
59         return this;
60     }
61
62     public PdpModifyRequestMapParams setDaoFactory(PolicyModelsProviderFactoryWrapper daoFactory) {
63         this.daoFactory = daoFactory;
64         return this;
65     }
66
67     public PdpModifyRequestMapParams setPolicyNotifier(PolicyNotifier policyNotifier) {
68         this.policyNotifier = policyNotifier;
69         return this;
70     }
71
72     public PdpModifyRequestMapParams setPdpPublisher(Publisher<PdpMessage> pdpPublisher) {
73         this.pdpPublisher = pdpPublisher;
74         return this;
75     }
76
77     public PdpModifyRequestMapParams setResponseDispatcher(RequestIdDispatcher<PdpStatus> responseDispatcher) {
78         this.responseDispatcher = responseDispatcher;
79         return this;
80     }
81
82     public PdpModifyRequestMapParams setModifyLock(Object modifyLock) {
83         this.modifyLock = modifyLock;
84         return this;
85     }
86
87     /**
88      * Validates the parameters.
89      */
90     public void validate() {
91         if (pdpPublisher == null) {
92             throw new IllegalArgumentException("missing publisher");
93         }
94
95         if (responseDispatcher == null) {
96             throw new IllegalArgumentException("missing responseDispatcher");
97         }
98
99         if (modifyLock == null) {
100             throw new IllegalArgumentException("missing modifyLock");
101         }
102
103         if (params == null) {
104             throw new IllegalArgumentException("missing PDP parameters");
105         }
106
107         if (updateTimers == null) {
108             throw new IllegalArgumentException("missing updateTimers");
109         }
110
111         if (stateChangeTimers == null) {
112             throw new IllegalArgumentException("missing stateChangeTimers");
113         }
114
115         if (daoFactory == null) {
116             throw new IllegalArgumentException("missing DAO factory");
117         }
118
119         if (policyNotifier == null) {
120             throw new IllegalArgumentException("missing policy notifier");
121         }
122     }
123 }