use of org.yaml.snakeyaml.TypeDescription in project jstorm by alibaba.
the class FluxParser method yaml.
private static Yaml yaml() {
Constructor constructor = new Constructor(TopologyDef.class);
TypeDescription topologyDescription = new TypeDescription(TopologyDef.class);
topologyDescription.putListPropertyType("spouts", SpoutDef.class);
topologyDescription.putListPropertyType("bolts", BoltDef.class);
topologyDescription.putListPropertyType("includes", IncludeDef.class);
constructor.addTypeDescription(topologyDescription);
Yaml yaml = new Yaml(constructor);
return yaml;
}
use of org.yaml.snakeyaml.TypeDescription in project camel by apache.
the class SnakeYAMLDataFormat method defaultConstructor.
// ***************************
// Defaults
// ***************************
private BaseConstructor defaultConstructor(CamelContext context) {
ClassLoader yamlClassLoader = this.classLoader;
Collection<TypeFilter> yamlTypeFilters = this.typeFilters;
if (yamlClassLoader == null && useApplicationContextClassLoader) {
yamlClassLoader = context.getApplicationContextClassLoader();
}
if (allowAnyType) {
yamlTypeFilters = Collections.singletonList(TypeFilters.allowAll());
}
BaseConstructor yamlConstructor;
if (yamlTypeFilters != null) {
yamlConstructor = yamlClassLoader != null ? typeFilterConstructor(yamlClassLoader, yamlTypeFilters) : typeFilterConstructor(yamlTypeFilters);
} else {
yamlConstructor = new SafeConstructor();
}
if (typeDescriptions != null && yamlConstructor instanceof Constructor) {
for (TypeDescription typeDescription : typeDescriptions) {
((Constructor) yamlConstructor).addTypeDescription(typeDescription);
}
}
return yamlConstructor;
}
use of org.yaml.snakeyaml.TypeDescription in project eiger by wlloyd.
the class CliClient method loadHelp.
private CliUserHelp loadHelp() {
final InputStream is = CliClient.class.getClassLoader().getResourceAsStream("org/apache/cassandra/cli/CliHelp.yaml");
assert is != null;
try {
final Constructor constructor = new Constructor(CliUserHelp.class);
TypeDescription desc = new TypeDescription(CliUserHelp.class);
desc.putListPropertyType("commands", CliCommandHelp.class);
final Yaml yaml = new Yaml(new Loader(constructor));
return (CliUserHelp) yaml.load(is);
} finally {
FileUtils.closeQuietly(is);
}
}
use of org.yaml.snakeyaml.TypeDescription in project storm by apache.
the class FluxParser method yaml.
private static Yaml yaml() {
Constructor constructor = new Constructor(TopologyDef.class);
TypeDescription topologyDescription = new TypeDescription(TopologyDef.class);
topologyDescription.putListPropertyType("spouts", SpoutDef.class);
topologyDescription.putListPropertyType("bolts", BoltDef.class);
topologyDescription.putListPropertyType("includes", IncludeDef.class);
constructor.addTypeDescription(topologyDescription);
Yaml yaml = new Yaml(constructor);
return yaml;
}
use of org.yaml.snakeyaml.TypeDescription in project Essentials by drtshock.
the class YamlStorageReader method prepareConstructor.
private void prepareConstructor(final Constructor constructor, final Set<Class> classes, final Class clazz) {
classes.add(clazz);
final TypeDescription description = new TypeDescription(clazz);
for (Field field : clazz.getDeclaredFields()) {
prepareList(field, description, classes, constructor);
prepareMap(field, description, classes, constructor);
if (StorageObject.class.isAssignableFrom(field.getType()) && !classes.contains(field.getType())) {
prepareConstructor(constructor, classes, field.getType());
}
}
constructor.addTypeDescription(description);
}
Aggregations