Fix sonars in models
[policy/models.git] / models-pdp / src / main / java / org / onap / policy / models / pdp / concepts / PdpUpdate.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  *  Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
5  *  Modifications Copyright (C) 2021 Nordix Foundation.
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  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.models.pdp.concepts;
24
25 import java.util.LinkedList;
26 import java.util.List;
27 import java.util.stream.Collectors;
28 import lombok.EqualsAndHashCode;
29 import lombok.Getter;
30 import lombok.Setter;
31 import lombok.ToString;
32 import org.onap.policy.models.pdp.enums.PdpMessageType;
33 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
34 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
35
36 /**
37  * Class to represent the PDP_UPDATE message that PAP will send to a PDP. When a PDP
38  * receives this message, it should save the group and subgroup and pass them to
39  * {@link #appliesTo(String, String, String)} of subsequent messages that it receives.
40  *
41  * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
42  */
43 @Getter
44 @Setter
45 @ToString(callSuper = true)
46 @EqualsAndHashCode(callSuper = true)
47 public class PdpUpdate extends PdpMessage {
48
49     /**
50      * System from which the message originated.
51      */
52     private String source;
53
54     /**
55      * Description of the PDP group.
56      */
57     private String description;
58
59     private Long pdpHeartbeatIntervalMs;
60
61     /**
62      * Policies that the PDP should deploy.
63      */
64     private List<ToscaPolicy> policiesToBeDeployed = new LinkedList<>();
65
66     /**
67      * Policies that the PDP should undeploy.
68      */
69     private List<ToscaConceptIdentifier> policiesToBeUndeployed = new LinkedList<>();
70
71     /**
72      * Constructor for instantiating PdpUpdate class with message name.
73      *
74      */
75     public PdpUpdate() {
76         super(PdpMessageType.PDP_UPDATE);
77     }
78
79     /**
80      * Constructs the object, making a deep copy.
81      *
82      * @param source source from which to copy
83      */
84     public PdpUpdate(PdpUpdate source) {
85         super(source);
86
87         this.source = source.source;
88         this.description = source.description;
89         this.pdpHeartbeatIntervalMs = source.pdpHeartbeatIntervalMs;
90         this.policiesToBeDeployed = (source.policiesToBeDeployed == null ? null
91                 : source.policiesToBeDeployed.stream().map(ToscaPolicy::new).collect(Collectors.toList()));
92         this.policiesToBeUndeployed = (source.policiesToBeUndeployed == null ? null
93                 : source.policiesToBeUndeployed.stream().map(ToscaConceptIdentifier::new).collect(Collectors.toList()));
94     }
95 }