All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.alloyggp.tournament.api.TournamentSpecParser Maven / Gradle / Ivy

There is a newer version: 0.1.0
Show newest version
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));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy