2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.onap.clamp.policy.pdpgroup;
26 import com.google.gson.JsonArray;
27 import com.google.gson.JsonObject;
28 import com.google.gson.annotations.Expose;
30 import java.util.List;
33 * This class maps the get Pdp Group response to a nice pojo.
35 public class PdpGroup {
41 private String pdpGroupState;
44 private List<PdpSubgroup> pdpSubgroups;
46 public String getName() {
50 public void setName(String name) {
54 public String getPdpGroupState() {
58 public void setPdpGroupState(String pdpGroupState) {
59 this.pdpGroupState = pdpGroupState;
62 public List<PdpSubgroup> getPdpSubgroups() {
66 public void setPdpSubgroups(List<PdpSubgroup> pdpSubgroups) {
67 this.pdpSubgroups = pdpSubgroups;
71 * Get supported subGroups based on the defined policy type and version.
72 * @param policyType The policy type
73 * @param version The version
74 * @return The supported subGroup list in Json format
76 public JsonObject getSupportedSubgroups(String policyType, String version) {
77 if (!pdpGroupState.equalsIgnoreCase("ACTIVE")) {
80 JsonArray supportedSubgroups = new JsonArray();
81 for (PdpSubgroup subGroup : pdpSubgroups) {
82 if (subGroup.getSupportedPolicyTypes().contains(new PolicyModelKey(policyType, version))) {
83 supportedSubgroups.add(subGroup.getPdpType());
86 if (supportedSubgroups.size() > 0) {
87 JsonObject supportedPdpGroup = new JsonObject();
88 supportedPdpGroup.add(this.name, supportedSubgroups);
89 return supportedPdpGroup;