use of org.yaml.snakeyaml.representer.Representer in project ozone by apache.
the class ContainerDataYaml method getYamlForContainerType.
/**
* Given a ContainerType this method returns a Yaml representation of
* the container properties.
*
* @param containerType type of container
* @return Yamal representation of container properties
*
* @throws StorageContainerException if the type is unrecognized
*/
public static Yaml getYamlForContainerType(ContainerType containerType) throws StorageContainerException {
PropertyUtils propertyUtils = new PropertyUtils();
propertyUtils.setBeanAccess(BeanAccess.FIELD);
propertyUtils.setAllowReadOnlyProperties(true);
switch(containerType) {
case KeyValueContainer:
Representer representer = new ContainerDataRepresenter();
representer.setPropertyUtils(propertyUtils);
representer.addClassTag(KeyValueContainerData.class, KeyValueContainerData.KEYVALUE_YAML_TAG);
Constructor keyValueDataConstructor = new ContainerDataConstructor();
return new Yaml(keyValueDataConstructor, representer);
default:
throw new StorageContainerException("Unrecognized container Type " + "format " + containerType, ContainerProtos.Result.UNKNOWN_CONTAINER_TYPE);
}
}
use of org.yaml.snakeyaml.representer.Representer in project Eidolons by IDemiurge.
the class YamlParser method main.
public static void main(String[] s) throws FileNotFoundException {
Representer representer = new Representer();
representer.addClassTag(YamlEntity.class, new Tag("!yah"));
Yaml yaml = new Yaml(representer);
Object load = yaml.load(new FileInputStream(new File("C:\\code\\Eidolons\\DungeonCraft\\src\\main\\resources\\data\\data.yaml")));
load.getClass();
}
Aggregations