public <T> T loadAndPrintValidationErrors(InputStream inputStream, BiFunction<ConfigSchema, Boolean, T> resultHandler) throws IOException, SchemaLoaderException { ConvertableSchema<ConfigSchema> configSchema = SchemaLoader.loadConvertableSchemaFromYaml(inputStream); boolean valid = true; if (!configSchema.isValid()) { System.out.println("Found the following errors when parsing the configuration according to its version. (" + configSchema.getVersion() + ")"); configSchema.getValidationIssues().forEach(s -> System.out.println(s)); System.out.println(); valid = false; configSchema.clearValidationIssues(); } else { System.out.println("No errors found when parsing configuration according to its version. (" + configSchema.getVersion() + ")"); } ConfigSchema currentSchema = configSchema.convert(); if (!currentSchema.isValid()) { System.out.println("Found the following errors when converting configuration to latest version. (" + ConfigSchema.CONFIG_VERSION + ")"); currentSchema.getValidationIssues().forEach(s -> System.out.println(s)); System.out.println(); valid = false; } else if (configSchema.getVersion() == currentSchema.getVersion()) { System.out.println("Configuration was already latest version (" + ConfigSchema.CONFIG_VERSION + ") so no conversion was needed."); } else { System.out.println("No errors found when converting configuration to latest version. (" + ConfigSchema.CONFIG_VERSION + ")"); } return resultHandler.apply(currentSchema, valid); }
public <T> T loadAndPrintValidationErrors(InputStream inputStream, BiFunction<ConfigSchema, Boolean, T> resultHandler) throws IOException, SchemaLoaderException { ConvertableSchema<ConfigSchema> configSchema = SchemaLoader.loadConvertableSchemaFromYaml(inputStream); boolean valid = true; if (!configSchema.isValid()) { System.out.println("Found the following errors when parsing the configuration according to its version. (" + configSchema.getVersion() + ")"); configSchema.getValidationIssues().forEach(s -> System.out.println(s)); System.out.println(); valid = false; configSchema.clearValidationIssues(); } else { System.out.println("No errors found when parsing configuration according to its version. (" + configSchema.getVersion() + ")"); } ConfigSchema currentSchema = configSchema.convert(); if (!currentSchema.isValid()) { System.out.println("Found the following errors when converting configuration to latest version. (" + ConfigSchema.CONFIG_VERSION + ")"); currentSchema.getValidationIssues().forEach(s -> System.out.println(s)); System.out.println(); valid = false; } else if (configSchema.getVersion() == currentSchema.getVersion()) { System.out.println("Configuration was already latest version (" + ConfigSchema.CONFIG_VERSION + ") so no conversion was needed."); } else { System.out.println("No errors found when converting configuration to latest version. (" + ConfigSchema.CONFIG_VERSION + ")"); } return resultHandler.apply(currentSchema, valid); }
configSchema.getValidationIssues().forEach(System.out::println); System.out.println(); } else {
configSchema.getValidationIssues().forEach(System.out::println); System.out.println(); } else {