net.alloyggp.tournament.api.TournamentSpecParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ggp-tournament Show documentation
Show all versions of ggp-tournament Show documentation
A library for GGP tournament specification and scheduling.
package net.alloyggp.tournament.api;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.yaml.snakeyaml.Yaml;
import net.alloyggp.tournament.spec.TournamentSpec;
public class TournamentSpecParser {
private TournamentSpecParser() {
//not instantiable
}
/**
* Loads and parses a tournament specification in YAML format and returns the
* specification.
*/
public static Tournament parseYamlFile(File file) {
try (InputStream in = new BufferedInputStream(new FileInputStream(file))) {
return TournamentSpec.parseYamlRootObject(new Yaml().load(in));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* Loads and parses a tournament specification in YAML format and returns the
* specification.
*/
public static Tournament parseYamlString(String yamlString) {
return TournamentSpec.parseYamlRootObject(new Yaml().load(yamlString));
}
}