package eu.svjatoslav.instantlauncher.configuration;
+import com.esotericsoftware.yamlbeans.YamlConfig;
import com.esotericsoftware.yamlbeans.YamlReader;
import com.esotericsoftware.yamlbeans.YamlWriter;
private void loadConfigFile(File propertiesFile) throws IOException {
YamlReader reader = new YamlReader(new FileReader(propertiesFile));
+ configureYaml(reader.getConfig());
configuration = reader.read(Configuration.class);
if (configuration == null)
initDefaultConfiguration();
private void saveConfigFile() throws IOException {
YamlWriter writer = new YamlWriter(new FileWriter(getPropertiesFile()));
- writer.getConfig().setClassTag("configuration", Configuration.class);
- writer.getConfig().setPropertyElementType(Configuration.class, "fileAssociations", FileAssociation.class);
+ configureYaml(writer.getConfig());
writer.write(configuration);
writer.close();
}
+ private void configureYaml(YamlConfig config) {
+ config.setClassTag("configuration", Configuration.class);
+ config.setPropertyElementType(Configuration.class, "fileAssociations", FileAssociation.class);
+ }
+
private void registerFileAssociation(String fileRegex, String command) {
FileAssociation association = new FileAssociation(fileRegex, command);
configuration.fileAssociations.add(association);