Add copy constructors for models-pap
[policy/models.git] / models-pap / src / main / java / org / onap / policy / models / pap / concepts / PdpGroup.java
index 148168d..a42ac21 100644 (file)
@@ -1,6 +1,7 @@
-/*-
+/*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.policy.models.pap.concepts;
 
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-
 import lombok.Getter;
+import lombok.NonNull;
 import lombok.Setter;
 import lombok.ToString;
-
+import org.onap.policy.models.base.PfUtils;
 import org.onap.policy.pdp.common.enums.PdpState;
 
 /**
@@ -41,9 +43,29 @@ public class PdpGroup {
 
     private String name;
     private String version;
-    private PdpState pdpGroupstate;
+    private PdpState pdpGroupState;
     private String description;
     private Map<String, String> properties;
     private List<PdpSubGroup> pdpSubgroups;
 
+    /**
+     * Constructs the object.
+     */
+    public PdpGroup() {
+        super();
+    }
+
+    /**
+     * Constructs the object, making a deep copy from the source.
+     *
+     * @param source source from which to copy fields
+     */
+    public PdpGroup(@NonNull PdpGroup source) {
+        this.name = source.name;
+        this.version = source.version;
+        this.pdpGroupState = source.pdpGroupState;
+        this.description = source.description;
+        this.properties = (source.properties == null ? null : new LinkedHashMap<>(source.properties));
+        this.pdpSubgroups = PfUtils.mapList(source.pdpSubgroups, PdpSubGroup::new);
+    }
 }