class ApiModelBuilder {

    public ApiModel buildApiModel(String sourceFileName) {
        RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(sourceFileName);
        log.debug("Finished parsing");
        if (ramlModelResult.hasErrors()) {
            StringBuilder builder = new StringBuilder("RAML syntax errors:\n");
            for (ValidationResult result : ramlModelResult.getValidationResults()) {
                builder.append(result.getPath());
                builder.append(": ");
                builder.append(result.getMessage());
            }
            throw new ParserException(builder.toString());
        }

        Api api = ramlModelResult.getApiV10();
        return new ApiModel(api);
    }

}