Skip to content

Commit 6119419

Browse files
continue validation
1 parent e0d8905 commit 6119419

6 files changed

Lines changed: 305 additions & 65 deletions

File tree

plugins/iac/nimble/src/main/java/org/apache/cloudstack/tosca/model/ToscaNodeTemplate.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,24 @@
2222
public class ToscaNodeTemplate {
2323
private final String name;
2424
private final ToscaNodeType type;
25-
private final Map<String, ToscaProperty> properties = new HashMap<>();
25+
private final Map<String, ToscaProperty> properties;
2626
private final Map<String, Object> attributes = new HashMap<>();
2727

28-
public ToscaNodeTemplate(String name, ToscaNodeType type) {
28+
public ToscaNodeTemplate(String name, ToscaNodeType type, Map<String, ToscaProperty> properties) {
2929
this.name = name;
3030
this.type = type;
31+
this.properties = properties;
3132
}
3233

3334
public String getName() {
3435
return name;
3536
}
3637

37-
public void addProperty(String name, ToscaProperty property) {
38-
properties.put(name, property);
38+
public boolean hasProperty(String name) {
39+
return properties.containsKey(name);
3940
}
4041

41-
public void addAttribute(String name, Object value) {
42-
attributes.put(name, value);
42+
public ToscaProperty getProperty(String name) {
43+
return properties.get(name);
4344
}
4445
}

plugins/iac/nimble/src/main/java/org/apache/cloudstack/tosca/model/ToscaProperty.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ public ToscaProperty(ToscaPropertyDefinition definition, Object rawValue, Object
2626
this.rawValue = rawValue;
2727
this.evaluatedValue = evaluatedValue;
2828
}
29+
30+
public Object getRawValue() {
31+
return rawValue;
32+
}
33+
34+
public ToscaPropertyDefinition getDefinition() {
35+
return definition;
36+
}
2937
}

plugins/iac/nimble/src/main/java/org/apache/cloudstack/tosca/model/ToscaTypeDefinition.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,22 @@ private boolean isCompatibleWithDataType(Object value) {
121121
});
122122
}
123123

124+
public boolean isAssignableFrom(ToscaTypeDefinition other) {
125+
if (kind != other.kind) return false;
126+
127+
if (kind == Kind.PRIMITIVE) {
128+
return primitiveType == other.primitiveType;
129+
}
130+
131+
if (kind == Kind.DATA_TYPE) {
132+
return dataType.getName().equals(other.dataType.getName());
133+
}
134+
135+
if (other.entrySchema == null) return false;
136+
137+
return entrySchema.isAssignableFrom(other.entrySchema);
138+
}
139+
124140
@Override
125141
public String toString() {
126142
if (kind == Kind.PRIMITIVE) {

0 commit comments

Comments
 (0)