diff options
author | Jim Hahn <jrh3@att.com> | 2019-03-31 01:15:57 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-03-31 01:21:46 -0400 |
commit | eb0b14eb7edbdea7410bb78db249bfe7fee2efd1 (patch) | |
tree | 51c9d6b799841fc3e0a10f684ff17f48ed04ac3d /models-pdp/src/main/java | |
parent | 96585ff6166369ae6c3f5326e56d55114ae6a3e0 (diff) |
Add copy constructors to more models-pdp classes
Change-Id: I9c6dc85b13e3e114f380dd9581f3f4c055889260
Issue-ID: POLICY-1542
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-pdp/src/main/java')
-rw-r--r-- | models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java | 17 | ||||
-rw-r--r-- | models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java | 19 |
2 files changed, 34 insertions, 2 deletions
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())); + } } |