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 {
*/
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);
}
public abstract boolean addWidget(Widget resource) throws XmlArtifactGenerationException;
- public abstract Widget.Type getWidgetType();
+ /**
+ * @return the Widget Type of this model.
+ */
+ public abstract WidgetType getWidgetType();
public abstract String getModelTypeName();
+ /**
+ * Check whether the model's Widget Type matches the supplied type.
+ *
+ * @param type
+ * the Widget Type to compare
+ * @return true if the Widget Type of this model matches the supplied type
+ */
+ public boolean hasWidgetType(String type) {
+ return getWidgetType() == WidgetType.valueOf(type);
+ }
+
public boolean addResource(Resource resource) {
return resources.add(resource);
}
* the model ident info
*/
public void populateModelIdentificationInformation(Map<String, String> modelIdentInfo) {
+ if (modelIdentInfo == null) {
+ return;
+ }
Iterator<String> iter = modelIdentInfo.keySet().iterator();
String property;
while (iter.hasNext()) {