Generate notifications when policies change
[policy/pap.git] / main / src / main / java / org / onap / policy / pap / main / parameters / RequestParams.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.comm.Publisher;
28 import org.onap.policy.pap.main.comm.TimerManager;
29
30
31 /**
32  * Parameters needed to create a Request.
33  */
34 @Getter
35 public class RequestParams {
36     private Publisher<PdpMessage> pdpPublisher;
37     private RequestIdDispatcher<PdpStatus> responseDispatcher;
38     private Object modifyLock;
39     private TimerManager timers;
40     private int maxRetryCount;
41
42
43     public RequestParams setPdpPublisher(Publisher<PdpMessage> publisher) {
44         this.pdpPublisher = publisher;
45         return this;
46     }
47
48     public RequestParams setResponseDispatcher(RequestIdDispatcher<PdpStatus> responseDispatcher) {
49         this.responseDispatcher = responseDispatcher;
50         return this;
51     }
52
53     public RequestParams setModifyLock(Object modifyLock) {
54         this.modifyLock = modifyLock;
55         return this;
56     }
57
58     public RequestParams setTimers(TimerManager timers) {
59         this.timers = timers;
60         return this;
61     }
62
63     public RequestParams setMaxRetryCount(int maxRetryCount) {
64         this.maxRetryCount = maxRetryCount;
65         return this;
66     }
67
68     /**
69      * Validates the parameters.
70      */
71     public void validate() {
72         if (pdpPublisher == null) {
73             throw new IllegalArgumentException("missing publisher");
74         }
75
76         if (responseDispatcher == null) {
77             throw new IllegalArgumentException("missing responseDispatcher");
78         }
79
80         if (modifyLock == null) {
81             throw new IllegalArgumentException("missing modifyLock");
82         }
83
84         if (timers == null) {
85             throw new IllegalArgumentException("missing timers");
86         }
87     }
88 }