aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java16
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java8
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/data/GroupConfiguration.java8
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java17
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/data/WidgetTypeConfig.java (renamed from src/main/java/org/onap/aai/babel/xml/generator/data/WidgetType.java)10
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/model/Model.java7
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java37
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/model/Service.java6
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java30
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/model/WidgetType.java73
10 files changed, 141 insertions, 71 deletions
diff --git a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java
index 6e37587..3f2e670 100644
--- a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java
+++ b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java
@@ -43,7 +43,7 @@ import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
import org.onap.aai.babel.xml.generator.model.Model;
import org.onap.aai.babel.xml.generator.model.Resource;
import org.onap.aai.babel.xml.generator.model.Widget;
-import org.onap.aai.babel.xml.generator.model.Widget.Type;
+import org.onap.aai.babel.xml.generator.model.WidgetType;
import org.onap.aai.babel.xml.generator.types.ModelType;
import org.onap.aai.cl.api.Logger;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
@@ -191,7 +191,7 @@ public class ArtifactGeneratorToscaParser {
}
public Resource createInstanceGroupModel(Map<String, String> properties) {
- Resource groupModel = new Resource(Type.INSTANCE_GROUP, true);
+ Resource groupModel = new Resource(WidgetType.valueOf("INSTANCE_GROUP"), true);
groupModel.populateModelIdentificationInformation(properties);
return groupModel;
}
@@ -238,7 +238,7 @@ public class ArtifactGeneratorToscaParser {
// Process each VF Group
for (Group serviceGroup : serviceGroups) {
Model groupModel = Model.getModelFor(serviceGroup.getType());
- if (groupModel.getWidgetType() == Type.VFMODULE) {
+ if (groupModel.getWidgetType() == WidgetType.valueOf("VFMODULE")) {
processVfModule(resources, resourceModel, serviceGroup, serviceNode, (Resource) groupModel);
}
}
@@ -258,8 +258,8 @@ public class ArtifactGeneratorToscaParser {
Resource model = Model.getModelFor(nodeTypeName, metaDataType);
if (metadata != null && hasAllottedResource(metadata.getAllProperties())
- && model.getWidgetType() == Type.VSERVER) {
- model = new Resource(Type.ALLOTTED_RESOURCE, false);
+ && model.getWidgetType() == WidgetType.valueOf("VSERVER")) {
+ model = new Resource(WidgetType.valueOf("ALLOTTED_RESOURCE"), false);
Map<String, Object> props = new HashMap<>();
props.put("providingService", true);
model.setProperties(props);
@@ -268,7 +268,7 @@ public class ArtifactGeneratorToscaParser {
foundProvidingService |= processModel(resourceModel, metadata, model, resourceNodeTemplate.getProperties());
}
- if (resourceModel.getWidgetType() == Type.ALLOTTED_RESOURCE && !foundProvidingService) {
+ if (resourceModel.getWidgetType() == WidgetType.valueOf("ALLOTTED_RESOURCE") && !foundProvidingService) {
final String modelInvariantId = resourceModel.getModelId();
throw new IllegalArgumentException(String.format(GENERATOR_AAI_PROVIDING_SERVICE_MISSING,
modelInvariantId == null ? "<null ID>" : modelInvariantId));
@@ -379,7 +379,7 @@ public class ArtifactGeneratorToscaParser {
log.debug(member.getType() + " mapped to " + resource);
- if (resource.getWidgetType() == Type.L3_NET) {
+ if (resource.getWidgetType() == WidgetType.valueOf("L3_NET")) {
// An l3-network inside a vf-module is treated as a Widget
resource.setModelType(ModelType.WIDGET);
}
@@ -426,7 +426,7 @@ public class ArtifactGeneratorToscaParser {
if (foundProvidingService) {
processProvidingService(resourceModel, resourceNode, nodeProperties);
} else if (resourceNode != null && resourceNode.getModelType() == ModelType.RESOURCE
- && resourceNode.getWidgetType() != Widget.Type.L3_NET) {
+ && resourceNode.getWidgetType() != WidgetType.valueOf("L3_NET")) {
if (metaData != null) {
resourceNode.populateModelIdentificationInformation(metaData.getAllProperties());
}
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java
index 52d342f..741c194 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java
@@ -44,8 +44,8 @@ import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
import org.onap.aai.babel.xml.generator.model.Model;
import org.onap.aai.babel.xml.generator.model.Resource;
import org.onap.aai.babel.xml.generator.model.Service;
+import org.onap.aai.babel.xml.generator.model.WidgetType;
import org.onap.aai.babel.xml.generator.model.Widget;
-import org.onap.aai.babel.xml.generator.model.Widget.Type;
import org.onap.aai.babel.xml.generator.types.ModelType;
import org.onap.aai.cl.api.Logger;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
@@ -242,8 +242,8 @@ public class AaiArtifactGenerator implements ArtifactGenerator {
if (model != null) {
Metadata metadata = nodeTemplate.getMetaData();
if (metadata != null && parser.hasAllottedResource(metadata.getAllProperties())
- && model.getWidgetType() == Type.VF) {
- model = new Resource(Type.ALLOTTED_RESOURCE, true);
+ && model.getWidgetType() == WidgetType.valueOf("VF")) {
+ model = new Resource(WidgetType.valueOf("ALLOTTED_RESOURCE"), true);
}
}
@@ -268,7 +268,7 @@ public class AaiArtifactGenerator implements ArtifactGenerator {
}
if (parser.hasSubCategoryTunnelXConnect(serviceMetadata) && parser.hasAllottedResource(serviceMetadata)) {
- resourceModel.addWidget(Widget.getWidget(Type.TUNNEL_XCONNECT));
+ resourceModel.addWidget(Widget.getWidget(WidgetType.valueOf("TUNNEL_XCONNECT")));
}
resources.addAll(parser.processInstanceGroups(resourceModel, nodeTemplate));
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/data/GroupConfiguration.java b/src/main/java/org/onap/aai/babel/xml/generator/data/GroupConfiguration.java
index 9d6409b..7ecd3f2 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/data/GroupConfiguration.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/data/GroupConfiguration.java
@@ -2,8 +2,8 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2019 European Software Marketing Ltd.
+ * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2017-2019 European Software Marketing Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public class GroupConfiguration {
/**
* Set of Widget Types.
*/
- private List<WidgetType> widgetTypes;
+ private List<WidgetTypeConfig> widgetTypes;
/**
* Mapping from TOSCA type to Widget directly.
@@ -44,7 +44,7 @@ public class GroupConfiguration {
return instanceGroupTypes;
}
- public List<WidgetType> getWidgetTypes() {
+ public List<WidgetTypeConfig> getWidgetTypes() {
return widgetTypes;
}
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java b/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java
index b340cd9..7683f7c 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java
@@ -31,8 +31,8 @@ import java.util.Optional;
import java.util.Properties;
import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
import org.onap.aai.babel.xml.generator.model.Resource;
+import org.onap.aai.babel.xml.generator.model.WidgetType;
import org.onap.aai.babel.xml.generator.model.Widget;
-import org.onap.aai.babel.xml.generator.model.Widget.Type;
import org.onap.aai.babel.xml.generator.types.ModelType;
public class WidgetConfigurationUtil {
@@ -69,8 +69,8 @@ public class WidgetConfigurationUtil {
return Optional.ofNullable(typeToResource.get(typePrefix));
}
- public static Widget createWidgetFromType(Type type) throws XmlArtifactGenerationException {
- Optional<Widget> widget = Optional.ofNullable(typeToWidget.get(type.toString()));
+ public static Widget createWidgetFromType(String widgetType) throws XmlArtifactGenerationException {
+ Optional<Widget> widget = Optional.ofNullable(typeToWidget.get(widgetType));
if (widget.isPresent()) {
// Make a copy of the Widget found in the mappings table.
return new Widget(widget.get());
@@ -78,25 +78,26 @@ public class WidgetConfigurationUtil {
return null;
}
- public static void setWidgetTypes(List<WidgetType> types) {
- for (WidgetType type : types) {
+ public static void setWidgetTypes(List<WidgetTypeConfig> types) {
+ for (WidgetTypeConfig type : types) {
if (type.type == null || type.name == null) {
throw new IllegalArgumentException("Incomplete widget type specified: " + type);
}
- Type widgetType = Widget.Type.valueOf(type.type);
+ WidgetType widgetType = new WidgetType(type.type);
Widget widget = new Widget(widgetType, type.name, type.deleteFlag);
typeToWidget.put(type.type, widget);
}
+ WidgetType.validateElements();
}
- public static void setWidgetMappings(List<WidgetMapping> mappings) throws IOException {
+ public static void setWidgetMappings(List<WidgetMapping> mappings) throws IOException {
for (WidgetMapping mapping : mappings) {
ModelType modelType = Optional.ofNullable(mapping.type).map(String::toUpperCase)
.map(s -> Enums.getIfPresent(ModelType.class, s).orNull()).orElse(null);
if (mapping.prefix == null || mapping.widget == null || modelType == null) {
throw new IOException("Invalid widget mapping specified: " + mapping);
}
- Resource resource = new Resource(Widget.Type.valueOf(mapping.widget), mapping.deleteFlag);
+ Resource resource = new Resource(WidgetType.valueOf(mapping.widget), mapping.deleteFlag);
resource.setModelType(modelType);
typeToResource.put(mapping.prefix, resource);
}
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetType.java b/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetTypeConfig.java
index 7691f0f..0d0fe6b 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetType.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetTypeConfig.java
@@ -2,8 +2,8 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2019 European Software Marketing Ltd.
+ * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2017-2019 European Software Marketing Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,11 @@
package org.onap.aai.babel.xml.generator.data;
-public class WidgetType {
+/**
+ * Widget Type as configured in the TOSCA Mappings.
+ *
+ */
+public class WidgetTypeConfig {
String type;
String name;
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java
index 12f1ac8..ea1d478 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java
@@ -30,7 +30,6 @@ import java.util.Optional;
import java.util.Set;
import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
-import org.onap.aai.babel.xml.generator.model.Widget.Type;
public abstract class Model {
@@ -148,9 +147,9 @@ public abstract class Model {
*/
public static Resource getModelFor(String toscaType, String metaDataType) {
if ("Configuration".equals(metaDataType)) {
- return new Resource(Type.CONFIGURATION, true);
+ return new Resource(WidgetType.valueOf("CONFIGURATION"), true);
} else if ("CR".equals(metaDataType)) {
- return new Resource(Type.CR, true);
+ return new Resource(WidgetType.valueOf("CR"), true);
} else {
return getModelFor(toscaType);
}
@@ -158,7 +157,7 @@ public abstract class Model {
public abstract boolean addWidget(Widget resource) throws XmlArtifactGenerationException;
- public abstract Widget.Type getWidgetType();
+ public abstract WidgetType getWidgetType();
public abstract String getModelTypeName();
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java
index 911bf32..f5f7c50 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java
@@ -25,12 +25,11 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
-import org.onap.aai.babel.xml.generator.model.Widget.Type;
import org.onap.aai.babel.xml.generator.types.ModelType;
public class Resource extends Model {
-
- private Type type;
+
+ private WidgetType type;
private boolean deleteFlag;
private ModelType modelType = ModelType.RESOURCE;
private Map<String, Object> properties = Collections.emptyMap();
@@ -40,7 +39,7 @@ public class Resource extends Model {
boolean addvolume = false;
List<String> members;
- public Resource(Type type, boolean deleteFlag) {
+ public Resource(WidgetType type, boolean deleteFlag) {
this.type = type;
this.deleteFlag = deleteFlag;
}
@@ -71,15 +70,15 @@ public class Resource extends Model {
public Map<String, Object> getProperties() {
return properties;
}
-
+
public void setModelType(ModelType type) {
this.modelType = type;
}
-
+
public ModelType getModelType() {
return modelType;
}
-
+
public void setMembers(List<String> members) {
this.members = members;
}
@@ -88,23 +87,23 @@ public class Resource extends Model {
* Adds a Widget.
*
* @param widget
- * the widget
+ * the widget
* @return the boolean
- * @throws XmlArtifactGenerationException
+ * @throws XmlArtifactGenerationException
*/
@Override
public boolean addWidget(Widget widget) throws XmlArtifactGenerationException {
- if (type == Type.VFMODULE) {
+ if (type == WidgetType.valueOf("VFMODULE")) {
if (widget.memberOf(members)) {
- if (vserver == null && widget.getWidgetType() == Type.VSERVER) {
+ if (vserver == null && widget.getWidgetType() == WidgetType.valueOf("VSERVER")) {
addVserverWidget(widget);
- } else if (widget.getWidgetType() == Type.LINT) {
+ } else if (widget.getWidgetType() == WidgetType.valueOf("LINT")) {
return addLIntfWidget(widget);
- } else if (widget.getWidgetType() == Type.VOLUME) {
+ } else if (widget.getWidgetType() == WidgetType.valueOf("VOLUME")) {
addVolumeWidget(widget);
return true;
}
- if (widget.getWidgetType() != Type.OAM_NETWORK) {
+ if (widget.getWidgetType() != WidgetType.valueOf("OAM_NETWORK")) {
return widgets.add(widget);
}
}
@@ -113,11 +112,11 @@ public class Resource extends Model {
return widgets.add(widget);
}
}
-
- public Type getWidgetType() {
+
+ public WidgetType getWidgetType() {
return type;
}
-
+
public String getModelTypeName() {
return "resource";
}
@@ -154,10 +153,10 @@ public class Resource extends Model {
private void addVserverWidget(Widget widget) throws XmlArtifactGenerationException {
vserver = widget;
if (addlintf) {
- vserver.addWidget(Widget.getWidget(Type.LINT));
+ vserver.addWidget(Widget.getWidget(WidgetType.valueOf("LINT")));
}
if (addvolume) {
- vserver.addWidget(Widget.getWidget(Type.VOLUME));
+ vserver.addWidget(Widget.getWidget(WidgetType.valueOf("VOLUME")));
}
}
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Service.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Service.java
index 6c96e96..0d20c2d 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/model/Service.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Service.java
@@ -21,8 +21,6 @@
package org.onap.aai.babel.xml.generator.model;
-import org.onap.aai.babel.xml.generator.model.Widget.Type;
-
public class Service extends Model {
@Override
@@ -31,8 +29,8 @@ public class Service extends Model {
}
@Override
- public Widget.Type getWidgetType() {
- return Type.SERVICE;
+ public WidgetType getWidgetType() {
+ return WidgetType.valueOf("SERVICE");
}
public String getModelTypeName() {
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java
index 2decc8c..732ec4d 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java
@@ -37,17 +37,13 @@ public class Widget extends Model {
public static final String GENERATOR_AAI_CONFIGLPROP_NOT_FOUND =
"Cannot generate artifacts. Widget configuration not found for %s";
- public enum Type {
- SERVICE, VF, VFC, VSERVER, VOLUME, FLAVOR, TENANT, VOLUME_GROUP, LINT, L3_NET, VFMODULE, IMAGE, OAM_NETWORK, ALLOTTED_RESOURCE, TUNNEL_XCONNECT, CONFIGURATION, CR, INSTANCE_GROUP;
- }
-
private Set<String> keys = new HashSet<>();
protected String name;
- protected Type type;
+ protected WidgetType type;
protected boolean deleteFlag = false;
- public Widget(Type widgetType, String name, boolean deleteFlag) {
+ public Widget(WidgetType widgetType, String name, boolean deleteFlag) {
type = widgetType;
this.name = name;
this.deleteFlag = deleteFlag;
@@ -61,25 +57,25 @@ public class Widget extends Model {
*/
public Widget(Widget baseWidget) throws XmlArtifactGenerationException {
this(baseWidget.getWidgetType(), baseWidget.getName(), baseWidget.getDeleteFlag());
- if (type == Type.VSERVER) {
- widgets.add(getWidget(Type.FLAVOR));
- widgets.add(getWidget(Type.IMAGE));
- widgets.add(getWidget(Type.TENANT));
- widgets.add(getWidget(Type.VFC));
+ if (type == WidgetType.valueOf("VSERVER")) {
+ widgets.add(getWidget(WidgetType.valueOf("FLAVOR")));
+ widgets.add(getWidget(WidgetType.valueOf("IMAGE")));
+ widgets.add(getWidget(WidgetType.valueOf("TENANT")));
+ widgets.add(getWidget(WidgetType.valueOf("VFC")));
}
}
/**
* Gets widget.
*
- * @param type
- * the type
+ * @param typeString
+ *
* @return a new widget of the specified type
* @throws XmlArtifactGenerationException
* if there is no configuration defined for the specified type
*/
- public static Widget getWidget(Type type) throws XmlArtifactGenerationException {
- Widget widget = WidgetConfigurationUtil.createWidgetFromType(type);
+ public static Widget getWidget(WidgetType type) throws XmlArtifactGenerationException {
+ Widget widget = WidgetConfigurationUtil.createWidgetFromType(type.toString());
if (widget == null) {
throw new XmlArtifactGenerationException("No widget type is defined for " + type);
}
@@ -126,7 +122,7 @@ public class Widget extends Model {
}
@Override
- public Type getWidgetType() {
+ public WidgetType getWidgetType() {
return type;
}
@@ -175,7 +171,7 @@ public class Widget extends Model {
@Override
public boolean addWidget(Widget widget) {
- if (getWidgetType() == Type.VSERVER) {
+ if (getWidgetType() == WidgetType.valueOf("VSERVER")) {
return widgets.add(widget);
}
return true;
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/WidgetType.java b/src/main/java/org/onap/aai/babel/xml/generator/model/WidgetType.java
new file mode 100644
index 0000000..2cab6ae
--- /dev/null
+++ b/src/main/java/org/onap/aai/babel/xml/generator/model/WidgetType.java
@@ -0,0 +1,73 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2017-2019 European Software Marketing Ltd.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.babel.xml.generator.model;
+
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Widget Type Enumeration.
+ *
+ */
+public class WidgetType {
+
+ /**
+ * Dynamically created set of Widget Types.
+ */
+ private static Map<String, WidgetType> elements = new LinkedHashMap<>();
+
+ /**
+ * Types that must be present for Model generation to function correctly.
+ */
+ private static final List<String> mandatoryElements = Arrays.asList( //
+ "SERVICE", "VF", "VFC", "VSERVER", "VOLUME", "FLAVOR", "TENANT", "VOLUME_GROUP", "LINT", "L3_NET",
+ "VFMODULE", "IMAGE", "OAM_NETWORK", "ALLOTTED_RESOURCE", "TUNNEL_XCONNECT", "CONFIGURATION", "CR",
+ "INSTANCE_GROUP");
+
+ private final String name;
+
+ public WidgetType(String name) {
+ this.name = name;
+ elements.put(name, this);
+ }
+
+ public static void validateElements() {
+ mandatoryElements.forEach(WidgetType::valueOf);
+ }
+
+ public static WidgetType valueOf(String typeName) {
+ WidgetType type = elements.get(typeName);
+ if (type == null) {
+ throw new IllegalArgumentException("Unknown type " + typeName);
+ }
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+}
+