Merge "Add copy constructors to more models-pdp classes"
authorLiam Fallon <liam.fallon@est.tech>
Mon, 1 Apr 2019 15:36:19 +0000 (15:36 +0000)
committerGerrit Code Review <gerrit@onap.org>
Mon, 1 Apr 2019 15:36:19 +0000 (15:36 +0000)
1  2 
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java

  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;
  import org.onap.policy.models.pdp.enums.PdpMessageType;
 -import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy;
 +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
  
  /**
   * Class to represent the PDP_UPDATE message that PAP will send to a PDP.
@@@ -53,4 -53,21 +53,21 @@@ public class PdpUpdate extends PdpMessa
      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()));
+     }
  }