use of org.eclipse.winery.model.tosca.yaml.YTSchemaDefinition in project winery by eclipse.
the class YamlBuilder method buildPropertyDefinition.
@Nullable
@SuppressWarnings("unchecked")
public <T> YTPropertyDefinition buildPropertyDefinition(Object object, Parameter<T> parameter) {
if (Objects.isNull(object)) {
return null;
}
if (!validate(parameter.getClazz(), object, parameter)) {
return null;
}
Map<String, Object> map = (Map<String, Object>) object;
String type = stringValue(map.get(YamlSpecKeywords.TYPE));
if (type == null) {
type = "string";
}
return new YTPropertyDefinition.Builder(buildQName(type)).setDescription(buildDescription(map.get(YamlSpecKeywords.DESCRIPTION))).setRequired(buildRequired(map.get(YamlSpecKeywords.REQUIRED))).setDefault(map.get(YamlSpecKeywords.DEFAULT)).setStatus(buildStatus(map.get(YamlSpecKeywords.STATUS))).addConstraints(buildList(map, YamlSpecKeywords.CONSTRAINTS, this::buildConstraintClause, parameter)).setEntrySchema(buildSchemaDefinition(map.get(YamlSpecKeywords.ENTRY_SCHEMA), new Parameter<YTSchemaDefinition>(parameter.getContext()).addContext(YamlSpecKeywords.ENTRY_SCHEMA))).setKeySchema(buildSchemaDefinition(map.get(YamlSpecKeywords.KEY_SCHEMA), new Parameter<YTSchemaDefinition>(parameter.getContext()).addContext(YamlSpecKeywords.KEY_SCHEMA))).build();
}
use of org.eclipse.winery.model.tosca.yaml.YTSchemaDefinition in project winery by eclipse.
the class YamlBuilder method buildParameterDefinition.
@Nullable
public YTParameterDefinition buildParameterDefinition(Object object, Parameter<YTParameterDefinition> parameter) {
if (Objects.isNull(object) || !validate(YTParameterDefinition.class, object, parameter)) {
return null;
}
@SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) object;
String type = stringValue(map.get(YamlSpecKeywords.TYPE));
if (type == null) {
type = "string";
}
return new YTParameterDefinition.Builder().setType(buildQName(type)).setDescription(buildDescription(map.get(YamlSpecKeywords.DESCRIPTION))).setRequired(buildRequired(map.get(YamlSpecKeywords.REQUIRED))).setDefault(map.get(YamlSpecKeywords.DEFAULT)).setStatus(buildStatus(map.get(YamlSpecKeywords.STATUS))).setConstraints(buildList(map, YamlSpecKeywords.CONSTRAINTS, this::buildConstraintClause, parameter)).setEntrySchema(buildSchemaDefinition(map.get(YamlSpecKeywords.ENTRY_SCHEMA), new Parameter<YTSchemaDefinition>(parameter.getContext()).addContext(YamlSpecKeywords.ENTRY_SCHEMA))).setKeySchema(buildSchemaDefinition(map.get(YamlSpecKeywords.KEY_SCHEMA), new Parameter<YTSchemaDefinition>(parameter.getContext()).addContext(YamlSpecKeywords.KEY_SCHEMA))).setValue(map.get(YamlSpecKeywords.VALUE)).build();
}
Aggregations