X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fbabel%2Fxml%2Fgenerator%2Fmodel%2FModel.java;h=b2020cdea69a781ddb6d54fe7c54d0f16277d01f;hb=6c585913c11b2e1973bfcd0d7671d4114e1c3e66;hp=12f1ac8ef9785de92f8c9e33724d5340a92f74a8;hpb=fbd05f86edf3e4710ab454780581f0ee40e152f6;p=aai%2Fbabel.git 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..b2020cd 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,10 +157,24 @@ public abstract class Model { 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); } @@ -222,6 +235,9 @@ public abstract class Model { * the model ident info */ public void populateModelIdentificationInformation(Map modelIdentInfo) { + if (modelIdentInfo == null) { + return; + } Iterator iter = modelIdentInfo.keySet().iterator(); String property; while (iter.hasNext()) {