54b9bb0f6d2f896bab959bc1fed26c737f08032f
[policy/engine.git] / PolicyEngineUtils / src / main / java / org / onap / policy / std / StdPDPNotification.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineUtils
4  * ================================================================================
5  * Copyright (C) 2017 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.std;
22
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.HashSet;
26 import org.onap.policy.api.LoadedPolicy;
27 import org.onap.policy.api.NotificationType;
28 import org.onap.policy.api.PDPNotification;
29 import org.onap.policy.api.RemovedPolicy;
30
31 public class StdPDPNotification implements PDPNotification {
32
33     private Collection<StdRemovedPolicy> removedPolicies = null;
34     private Collection<StdLoadedPolicy> loadedPolicies = null;
35     private Collection<RemovedPolicy> removed = null;
36     private Collection<LoadedPolicy> updated = null;
37     private NotificationType notificationType = null;
38
39     @Override
40     public Collection<RemovedPolicy> getRemovedPolicies() {
41         removed = new HashSet<>();
42         if (removedPolicies != null) {
43             removed.addAll(removedPolicies);
44             return this.removed;
45         }
46         return Collections.emptyList();
47     }
48
49     @Override
50     public Collection<LoadedPolicy> getLoadedPolicies() {
51         updated = new HashSet<>();
52         if (loadedPolicies != null) {
53             updated.addAll(loadedPolicies);
54             return updated;
55         }
56         return Collections.emptyList();
57     }
58
59     @Override
60     public NotificationType getNotificationType() {
61         return notificationType;
62     }
63
64     public void setNotificationType(NotificationType notificationType) {
65         this.notificationType = notificationType;
66     }
67
68     public void setLoadedPolicies(Collection<StdLoadedPolicy> loadedPolicies) {
69         this.loadedPolicies = loadedPolicies;
70     }
71
72     public void setRemovedPolicies(Collection<StdRemovedPolicy> removedPolicies) {
73         this.removedPolicies = removedPolicies;
74     }
75 }