2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2019 European Software Marketing Ltd.
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=========================================================
21 package org.onap.aai.babel.xml.generator.data;
23 import java.util.Collections;
24 import java.util.HashMap;
25 import java.util.List;
27 import java.util.Optional;
28 import java.util.Properties;
29 import org.onap.aai.babel.xml.generator.model.Resource;
30 import org.onap.aai.babel.xml.generator.model.Widget;
32 public class WidgetConfigurationUtil {
34 private static Properties config;
35 private static List<String> instanceGroups = Collections.emptyList();
36 private static Map<String, Resource> typeToWidget = new HashMap<>();
39 * Private constructor to prevent instantiation
41 private WidgetConfigurationUtil() {
42 throw new UnsupportedOperationException("This static class should not be instantiated!");
45 public static Properties getConfig() {
49 public static void setConfig(Properties config) {
50 WidgetConfigurationUtil.config = config;
53 public static void setSupportedInstanceGroups(List<String> supportedInstanceGroups) {
54 instanceGroups = supportedInstanceGroups;
57 public static boolean isSupportedInstanceGroup(String groupType) {
58 return instanceGroups.contains(groupType);
61 public static Optional<Resource> createModelFromType(String typePrefix) {
62 return Optional.ofNullable(typeToWidget.get(typePrefix));
65 public static void setWidgetMappings(List<WidgetMapping> mappings) {
66 for (WidgetMapping mapping : mappings) {
67 Resource resource = new Resource(Widget.Type.valueOf(mapping.widget), mapping.deleteFlag);
68 resource.setIsResource(mapping.type.equalsIgnoreCase("resource"));
69 typeToWidget.put(mapping.prefix, resource);