From eb0b14eb7edbdea7410bb78db249bfe7fee2efd1 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Sun, 31 Mar 2019 01:15:57 -0400 Subject: Add copy constructors to more models-pdp classes Change-Id: I9c6dc85b13e3e114f380dd9581f3f4c055889260 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn --- .../policy/models/pdp/concepts/PdpStateChange.java | 17 ++++++++++++++++- .../onap/policy/models/pdp/concepts/PdpUpdate.java | 19 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'models-pdp/src/main/java') diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java index bca162e91..d8f938bbc 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java @@ -28,7 +28,8 @@ import org.onap.policy.models.pdp.enums.PdpMessageType; import org.onap.policy.models.pdp.enums.PdpState; /** - * Class to represent the PDP_STATE_CHANGE message that PAP will send to either PDPGroup/Subgroup or a PDP. + * Class to represent the PDP_STATE_CHANGE message that PAP will send to either + * PDPGroup/Subgroup or a PDP. * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ @@ -49,4 +50,18 @@ public class PdpStateChange extends PdpMessage { public PdpStateChange() { super(PdpMessageType.PDP_STATE_CHANGE); } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public PdpStateChange(PdpStateChange source) { + super(PdpMessageType.PDP_STATE_CHANGE); + + this.name = source.name; + this.state = source.state; + this.pdpGroup = source.pdpGroup; + this.pdpSubgroup = source.pdpSubgroup; + } } diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java index a048cde48..fbf19f14f 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java @@ -22,7 +22,7 @@ package org.onap.policy.models.pdp.concepts; import java.util.List; - +import java.util.stream.Collectors; import lombok.Getter; import lombok.Setter; import lombok.ToString; @@ -53,4 +53,21 @@ public class PdpUpdate extends PdpMessage { public PdpUpdate() { super(PdpMessageType.PDP_UPDATE); } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public PdpUpdate(PdpUpdate source) { + super(PdpMessageType.PDP_UPDATE); + + this.name = source.name; + this.pdpType = source.pdpType; + this.description = source.description; + this.pdpGroup = source.pdpGroup; + this.pdpSubgroup = source.pdpSubgroup; + this.policies = (source.policies == null ? null + : source.policies.stream().map(ToscaPolicy::new).collect(Collectors.toList())); + } } -- cgit 1.2.3-korg