/** * Creates a new FileConfig based on the specified file. The format is detected automatically. * * @param file the file to use to save and load the config * @return a new FileConfig associated to the specified file * * @throws NoFormatFoundException if the format detection fails */ static FileConfig of(File file) { ConfigFormat<?> format = FormatDetector.detect(file); if (format == null) { throw new NoFormatFoundException("No suitable format for " + file.getName()); } return of(file, format); }
/** * Returns a CommentedFileConfigBuilder to create a CommentedFileConfig with many options. The * format is detected automatically. * * @param file the file to use to save and load the config * @return a new FileConfigBuilder that will build a CommentedFileConfig associated to the * specified file * * @throws NoFormatFoundException if the format detection fails */ static CommentedFileConfigBuilder builder(Path file) { ConfigFormat format = FormatDetector.detect(file); if (format == null) { throw new NoFormatFoundException("No suitable format for " + file.getFileName()); } else if (!format.supportsComments()) { throw new NoFormatFoundException( "The available format doesn't support comments for " + file.getFileName()); } return builder(file, format); }
/** * Returns a CommentedFileConfigBuilder to create a CommentedFileConfig with many options. The * format is detected automatically. * * @param file the file to use to save and load the config * @return a new FileConfigBuilder that will build a CommentedFileConfig associated to the * specified file * * @throws NoFormatFoundException if the format detection fails */ static CommentedFileConfigBuilder builder(File file) { ConfigFormat format = FormatDetector.detect(file); if (format == null) { throw new NoFormatFoundException("No suitable format for " + file.getName()); } else if (!format.supportsComments()) { throw new NoFormatFoundException( "The available format doesn't support comments for " + file.getName()); } return builder(file, format); }
/** * Returns a FileConfigBuilder to create a FileConfig with many options. The format is detected * automatically. * * @param file the file to use to save and load the config * @return a new FileConfigBuilder that will build a FileConfig associated to the specified file * * @throws NoFormatFoundException if the format detection fails */ static FileConfigBuilder builder(File file) { ConfigFormat<?> format = FormatDetector.detect(file); if (format == null) { throw new NoFormatFoundException("No suitable format for " + file.getName()); } return builder(file, format); }
/** * Creates a new FileConfig based on the specified file. The format is detected automatically. * * @param file the file to use to save and load the config * @return a new FileConfig associated to the specified file * * @throws NoFormatFoundException if the format detection fails */ static FileConfig of(Path file) { ConfigFormat<?> format = FormatDetector.detect(file); if (format == null) { throw new NoFormatFoundException("No suitable format for " + file.getFileName()); } return of(file, format); }
/** * Returns a FileConfigBuilder to create a FileConfig with many options. The format is detected * automatically. * * @param file the file to use to save and load the config * @return a new FileConfigBuilder that will build a FileConfig associated to the specified file * * @throws NoFormatFoundException if the format detection fails */ static FileConfigBuilder builder(Path file) { ConfigFormat<?> format = FormatDetector.detect(file); if (format == null) { throw new NoFormatFoundException("No suitable format for " + file.getFileName()); } return builder(file, format); }
/** * Creates a new FileConfig based on the specified file and format. The format is detected * automatically. * * @param file the file to use to save and load the config * @return a new FileConfig associated to the specified file * * @throws NoFormatFoundException if the format detection fails */ static CommentedFileConfig of(Path file) { ConfigFormat format = FormatDetector.detect(file); if (format == null || !format.supportsComments()) { throw new NoFormatFoundException("No suitable format for " + file.getFileName()); } return of(file, format); }
/** * Creates a new FileConfig based on the specified file and format. The format is detected * automatically. * * @param file the file to use to save and load the config * @return a new FileConfig associated to the specified file * * @throws NoFormatFoundException if the format detection fails */ static CommentedFileConfig of(File file) { ConfigFormat format = FormatDetector.detect(file); if (format == null || !format.supportsComments()) { throw new NoFormatFoundException("No suitable format for " + file.getName()); } return of(file, format); }