aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/sdc/toscaparser/api/CapabilityAssignment.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/sdc/toscaparser/api/CapabilityAssignment.java')
-rw-r--r--src/main/java/org/onap/sdc/toscaparser/api/CapabilityAssignment.java182
1 files changed, 94 insertions, 88 deletions
diff --git a/src/main/java/org/onap/sdc/toscaparser/api/CapabilityAssignment.java b/src/main/java/org/onap/sdc/toscaparser/api/CapabilityAssignment.java
index 126c858..bb7b47d 100644
--- a/src/main/java/org/onap/sdc/toscaparser/api/CapabilityAssignment.java
+++ b/src/main/java/org/onap/sdc/toscaparser/api/CapabilityAssignment.java
@@ -7,9 +7,9 @@
* 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.
@@ -28,97 +28,103 @@ import org.onap.sdc.toscaparser.api.elements.CapabilityTypeDef;
import org.onap.sdc.toscaparser.api.elements.PropertyDef;
public class CapabilityAssignment {
-
- private String name;
- private LinkedHashMap<String,Object> _properties;
- private CapabilityTypeDef _definition;
- private LinkedHashMap<String, Object> _customDef;
-
- public CapabilityAssignment(String cname,
- LinkedHashMap<String, Object> cproperties,
- CapabilityTypeDef cdefinition, LinkedHashMap<String, Object> customDef) {
- name = cname;
- _properties = cproperties;
- _definition = cdefinition;
- _customDef = customDef;
- }
-
- /**
- * Get the properties list for capability
- * @return list of property objects for capability
- */
- public ArrayList<Property> getPropertiesObjects() {
- // Return a list of property objects
- ArrayList<Property> properties = new ArrayList<Property>();
- LinkedHashMap<String,Object> props = _properties;
- if(props != null) {
- for(Map.Entry<String,Object> me: props.entrySet()) {
- String pname = me.getKey();
- Object pvalue = me.getValue();
-
- LinkedHashMap<String,PropertyDef> propsDef = _definition.getPropertiesDef();
- if(propsDef != null) {
- PropertyDef pd = (PropertyDef)propsDef.get(pname);
- if(pd != null) {
- properties.add(new Property(pname,pvalue,pd.getSchema(), _customDef));
- }
- }
- }
- }
- return properties;
- }
-
- /**
- * Get the map of properties
- * @return map of all properties contains dictionary of property name and property object
- */
- public LinkedHashMap<String,Property> getProperties() {
+
+ private String name;
+ private LinkedHashMap<String, Object> _properties;
+ private CapabilityTypeDef _definition;
+ private LinkedHashMap<String, Object> _customDef;
+
+ public CapabilityAssignment(String cname,
+ LinkedHashMap<String, Object> cproperties,
+ CapabilityTypeDef cdefinition, LinkedHashMap<String, Object> customDef) {
+ name = cname;
+ _properties = cproperties;
+ _definition = cdefinition;
+ _customDef = customDef;
+ }
+
+ /**
+ * Get the properties list for capability
+ *
+ * @return list of property objects for capability
+ */
+ public ArrayList<Property> getPropertiesObjects() {
+ // Return a list of property objects
+ ArrayList<Property> properties = new ArrayList<Property>();
+ LinkedHashMap<String, Object> props = _properties;
+ if (props != null) {
+ for (Map.Entry<String, Object> me : props.entrySet()) {
+ String pname = me.getKey();
+ Object pvalue = me.getValue();
+
+ LinkedHashMap<String, PropertyDef> propsDef = _definition.getPropertiesDef();
+ if (propsDef != null) {
+ PropertyDef pd = (PropertyDef) propsDef.get(pname);
+ if (pd != null) {
+ properties.add(new Property(pname, pvalue, pd.getSchema(), _customDef));
+ }
+ }
+ }
+ }
+ return properties;
+ }
+
+ /**
+ * Get the map of properties
+ *
+ * @return map of all properties contains dictionary of property name and property object
+ */
+ public LinkedHashMap<String, Property> getProperties() {
// Return a dictionary of property name-object pairs
- LinkedHashMap<String,Property> npps = new LinkedHashMap<>();
- for(Property p: getPropertiesObjects()) {
- npps.put(p.getName(),p);
- }
- return npps;
- }
-
- /**
- * Get the property value by name
- * @param pname - the property name for capability
- * @return the property value for this name
- */
- public Object getPropertyValue(String pname) {
+ LinkedHashMap<String, Property> npps = new LinkedHashMap<>();
+ for (Property p : getPropertiesObjects()) {
+ npps.put(p.getName(), p);
+ }
+ return npps;
+ }
+
+ /**
+ * Get the property value by name
+ *
+ * @param pname - the property name for capability
+ * @return the property value for this name
+ */
+ public Object getPropertyValue(String pname) {
// Return the value of a given property name
- LinkedHashMap<String,Property> props = getProperties();
- if(props != null && props.get(pname) != null) {
+ LinkedHashMap<String, Property> props = getProperties();
+ if (props != null && props.get(pname) != null) {
return props.get(name).getValue();
}
return null;
- }
-
- /**
- * Get the name for capability
- * @return the name for capability
- */
- public String getName() {
- return name;
- }
-
- /**
- * Get the definition for capability
- * @return CapabilityTypeDef - contain definition for capability
- */
- public CapabilityTypeDef getDefinition() {
- return _definition;
- }
-
- /**
- * Set the property for capability
- * @param pname - the property name for capability to set
- * @param pvalue - the property valiue for capability to set
- */
- public void setProperty(String pname,Object pvalue) {
- _properties.put(pname,pvalue);
- }
+ }
+
+ /**
+ * Get the name for capability
+ *
+ * @return the name for capability
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get the definition for capability
+ *
+ * @return CapabilityTypeDef - contain definition for capability
+ */
+ public CapabilityTypeDef getDefinition() {
+ return _definition;
+ }
+
+ /**
+ * Set the property for capability
+ *
+ * @param pname - the property name for capability to set
+ * @param pvalue - the property valiue for capability to set
+ */
+ public void setProperty(String pname, Object pvalue) {
+ _properties.put(pname, pvalue);
+ }
@Override
public String toString() {