use of org.yaml.snakeyaml.representer.Representer in project mxgwd by kamax-io.
the class YamlConfigLoader method loadFromFile.
public static Config loadFromFile(String path) throws IOException {
Representer rep = new Representer();
rep.getPropertyUtils().setAllowReadOnlyProperties(true);
rep.getPropertyUtils().setSkipMissingProperties(true);
Yaml yaml = new Yaml(new Constructor(Config.class), rep);
Object o = yaml.load(new FileInputStream(path));
return GsonUtil.get().fromJson(GsonUtil.get().toJson(o), Config.class);
}
use of org.yaml.snakeyaml.representer.Representer in project pai by Microsoft.
the class YamlUtils method toObject.
// Bytes <-> Yaml
public static <T> T toObject(byte[] bytes, Class<T> classRef) {
Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);
Yaml yaml = new Yaml(new Constructor(classRef), representer);
return yaml.loadAs(new String(bytes), classRef);
}
use of org.yaml.snakeyaml.representer.Representer in project pai by Microsoft.
the class YamlUtils method toObject.
public static <T> T toObject(String fileName, Class<T> classRef) throws FileNotFoundException {
Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);
Yaml yaml = new Yaml(new Constructor(classRef), representer);
return yaml.loadAs(new FileReader(fileName), classRef);
}
use of org.yaml.snakeyaml.representer.Representer in project pom-manipulation-ext by release-engineering.
the class YamlTest method readYamlViaMap.
@Test
public void readYamlViaMap() throws ManipulationException, IOException {
Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);
Yaml y = new Yaml(representer);
Map config = (Map) y.load(new FileInputStream(yamlFile));
Map usersConfig = (Map) config.get("pme");
assertTrue(usersConfig.size() > 0);
}
use of org.yaml.snakeyaml.representer.Representer in project winery by eclipse.
the class ChefKitchenYmlParser method parseKitchen.
private Map<String, Object> parseKitchen() {
Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);
Yaml yaml = new Yaml();
InputStream inputStream = null;
try {
inputStream = new FileInputStream(this.cookbookPath + "/kitchen.yml");
} catch (FileNotFoundException e1) {
try {
inputStream = new FileInputStream(this.cookbookPath + "/.kitchen.yml");
} catch (FileNotFoundException e2) {
System.err.printf("Cookbook \" " + cookbookName + "\"" + " has no kitchen.yml file");
return null;
}
}
Map<String, Object> kitchenYml = yaml.load(inputStream);
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
return kitchenYml;
}
Aggregations