2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.models.pdp.concepts;
23 import java.util.ArrayList;
24 import java.util.List;
26 import lombok.NonNull;
27 import org.onap.policy.common.parameters.BeanValidationResult;
28 import org.onap.policy.common.parameters.ValidationResult;
29 import org.onap.policy.models.base.PfUtils;
30 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
33 * A deployment (i.e., set of policies) for all PDPs of the same pdp type running within a
37 public class DeploymentSubGroup {
40 POST, // all listed policies are to be added
41 DELETE, // all listed policies are to be deleted
42 PATCH // update the deployment so that the policies match exactly
45 private String pdpType;
46 private Action action;
47 private List<ToscaPolicyIdentifier> policies;
50 * Constructs the object.
52 public DeploymentSubGroup() {
57 * Constructs the object, making a deep copy from the source.
59 * @param source source from which to copy fields
61 public DeploymentSubGroup(@NonNull final DeploymentSubGroup source) {
62 this.pdpType = source.pdpType;
63 this.action = source.action;
64 this.policies = PfUtils.mapList(source.policies, ToscaPolicyIdentifier::new, new ArrayList<>(0));
68 * Validates that appropriate fields are populated for an incoming call to the PAP
71 * @return the validation result
73 public ValidationResult validatePapRest() {
74 BeanValidationResult result = new BeanValidationResult("group", this);
76 result.validateNotNull("pdpType", pdpType);
77 result.validateNotNull("action", action);
78 result.validateNotNullList("policies", policies, ToscaPolicyIdentifier::validatePapRest);