Search in sources :

Example 1 with YTSchemaDefinition

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();
}
Also used : YTSchemaDefinition(org.eclipse.winery.model.tosca.yaml.YTSchemaDefinition) YTMapObject(org.eclipse.winery.model.tosca.yaml.support.YTMapObject) YTListString(org.eclipse.winery.model.tosca.yaml.support.YTListString) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 2 with YTSchemaDefinition

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();
}
Also used : YTSchemaDefinition(org.eclipse.winery.model.tosca.yaml.YTSchemaDefinition) YTMapObject(org.eclipse.winery.model.tosca.yaml.support.YTMapObject) YTListString(org.eclipse.winery.model.tosca.yaml.support.YTListString) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 YTSchemaDefinition (org.eclipse.winery.model.tosca.yaml.YTSchemaDefinition)2 YTListString (org.eclipse.winery.model.tosca.yaml.support.YTListString)2 YTMapObject (org.eclipse.winery.model.tosca.yaml.support.YTMapObject)2