use of org.springframework.ide.vscode.commons.yaml.path.YamlTraversal in project sts4 by spring-projects.
the class ManifestConstraints method getConflictingNodesTraversal.
private static YamlTraversal getConflictingNodesTraversal(YamlPath path, String[] propertyIds) {
Assert.isLegal(propertyIds.length > 0);
YamlTraversal properties = null;
for (String id : propertyIds) {
properties = properties == null ? YamlPathSegment.keyAt(id) : properties.or(YamlPathSegment.keyAt(id));
}
YamlTraversal traversal = path.then(properties);
if (path.size() > 2) {
traversal = traversal.or(path.dropLast(2).then(properties));
}
return traversal;
}
use of org.springframework.ide.vscode.commons.yaml.path.YamlTraversal in project sts4 by spring-projects.
the class BoshCommandCloudConfigProvider method getModel.
@Override
public CloudConfigModel getModel(DynamicSchemaContext dc) throws Exception {
String block = getBlock();
YamlFileAST ast = parseYaml(block);
return new CloudConfigModel() {
@Override
public Collection<String> getVMTypes() {
return getNames(VM_TYPE_NAMES);
}
@Override
public Collection<String> getNetworkNames() {
return getNames(NETWORK_NAMES);
}
@Override
public Collection<String> getAvailabilityZones() {
return getNames(AVAILABILITY_ZONES);
}
@Override
public Collection<String> getDiskTypes() {
return getNames(DISK_TYPES);
}
@Override
public Collection<String> getVMExtensions() {
return getNames(VM_EXTENSIONS);
}
private Collection<String> getNames(YamlTraversal namesPath) {
return namesPath.traverseAmbiguously(ast).flatMap(nameNode -> {
String name = NodeUtil.asScalar(nameNode);
return StringUtil.hasText(name) ? Stream.of(name) : Stream.empty();
}).collect(CollectorUtil.toMultiset());
}
};
}
Aggregations