aboutsummaryrefslogtreecommitdiffstats
path: root/models-pap/src/main/java/org/onap
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-03-21 12:36:35 -0400
committerJim Hahn <jrh3@att.com>2019-03-21 17:11:31 -0400
commit834851e6c460ef8a28f356a64fe7b85d8bbf9a55 (patch)
treecfc520093e320e0875f0e5ce6d2540b00af09754 /models-pap/src/main/java/org/onap
parent99837f40d77dd41f80eeb4649c43479e898bcaff (diff)
Add copy constructors for models-pap
Also added a method to PfUtils to simplify cloning lists. Change-Id: Iae667be02cced57b0b9578e0a96c5cda38111b97 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-pap/src/main/java/org/onap')
-rw-r--r--models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpGroup.java30
-rw-r--r--models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpInstanceDetails.java24
-rw-r--r--models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java34
-rw-r--r--models-pap/src/main/java/org/onap/policy/models/pap/concepts/Policy.java24
4 files changed, 101 insertions, 11 deletions
diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpGroup.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpGroup.java
index 148168d89..a42ac21bd 100644
--- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpGroup.java
+++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpGroup.java
@@ -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.
@@ -20,13 +21,14 @@
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);
+ }
}
diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpInstanceDetails.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpInstanceDetails.java
index 168c20e38..4f9041c7f 100644
--- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpInstanceDetails.java
+++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpInstanceDetails.java
@@ -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.
@@ -21,9 +22,9 @@
package org.onap.policy.models.pap.concepts;
import lombok.Getter;
+import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
-
import org.onap.policy.pdp.common.enums.PdpHealthStatus;
import org.onap.policy.pdp.common.enums.PdpState;
@@ -41,4 +42,23 @@ public class PdpInstanceDetails {
private PdpState pdpState;
private PdpHealthStatus healthy;
private String message;
+
+ /**
+ * Constructs the object.
+ */
+ public PdpInstanceDetails() {
+ super();
+ }
+
+ /**
+ * Constructs the object, making a deep copy from the source.
+ *
+ * @param source source from which to copy fields
+ */
+ public PdpInstanceDetails(@NonNull PdpInstanceDetails source) {
+ this.instanceId = source.instanceId;
+ this.pdpState = source.pdpState;
+ this.healthy = source.healthy;
+ this.message = source.message;
+ }
}
diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java
index ebb476d92..e535233bc 100644
--- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java
+++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java
@@ -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.
@@ -20,15 +21,19 @@
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.PfConceptKey;
+import org.onap.policy.models.base.PfUtils;
/**
- * Class to represent a group of all PDP's of the same pdp type running for a particular domain.
+ * Class to represent a group of all PDP's of the same pdp type running for a particular
+ * domain.
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
@@ -38,11 +43,32 @@ import lombok.ToString;
public class PdpSubGroup {
private String pdpType;
- private List<String> supportedPolicyTypes;
+ private List<PfConceptKey> supportedPolicyTypes;
private List<Policy> policies;
private int currentInstanceCount;
private int desiredInstanceCount;
private Map<String, String> properties;
private List<PdpInstanceDetails> pdpInstances;
+ /**
+ * Constructs the object.
+ */
+ public PdpSubGroup() {
+ super();
+ }
+
+ /**
+ * Constructs the object, making a deep copy from the source.
+ *
+ * @param source source from which to copy fields
+ */
+ public PdpSubGroup(@NonNull PdpSubGroup source) {
+ this.pdpType = source.pdpType;
+ this.supportedPolicyTypes = PfUtils.mapList(source.supportedPolicyTypes, PfConceptKey::new);
+ this.policies = PfUtils.mapList(source.policies, Policy::new);
+ this.currentInstanceCount = source.currentInstanceCount;
+ this.desiredInstanceCount = source.desiredInstanceCount;
+ this.properties = (source.properties == null ? null : new LinkedHashMap<>(source.properties));
+ this.pdpInstances = PfUtils.mapList(source.pdpInstances, PdpInstanceDetails::new);
+ }
}
diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/Policy.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/Policy.java
index e1281fc51..b83510e83 100644
--- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/Policy.java
+++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/Policy.java
@@ -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.
@@ -21,6 +22,7 @@
package org.onap.policy.models.pap.concepts;
import lombok.Getter;
+import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
@@ -39,4 +41,24 @@ public class Policy {
private String policyType;
private String policyTypeVersion;
private String policyTypeImpl;
+
+ /**
+ * Constructs the object.
+ */
+ public Policy() {
+ super();
+ }
+
+ /**
+ * Constructs the object, making a deep copy from the source.
+ *
+ * @param source source from which to copy fields
+ */
+ public Policy(@NonNull Policy source) {
+ this.name = source.name;
+ this.policyVersion = source.policyVersion;
+ this.policyType = source.policyType;
+ this.policyTypeVersion = source.policyTypeVersion;
+ this.policyTypeImpl = source.policyTypeImpl;
+ }
}