@Test public void testReorder_orderByName() throws IOException { final Path propertiesRootDirectory= this.tmpFolder.getRoot().toPath(); final File f1= createI18nBundle(propertiesRootDirectory, "" + "keyC = valueC\n" + "keyB = valueB\n" + "keyA = valueA\n" + "keyE = valueE\n" + "keyD = valueD\n" ); final File f2= createI18nBundle(propertiesRootDirectory, "" + "keyE = valueE\n" + "keyD = valueD\n" + "keyC = valueC\n" + "keyB = valueB\n" + "keyA = valueA\n" ); final FileMatcher fileMatcher= new FileMatcher(propertiesRootDirectory, new String[]{"**/*.properties"}, new String[]{""}); new KiltReformatter() .reorderByKey(fileMatcher, AttachCommentsTo.NEXT_PROPERTY, UTF_8); assertThat(contentOf(f1)).isEqualTo("" + "keyA = valueA\n" + "keyB = valueB\n" + "keyC = valueC\n" + "keyD = valueD\n" + "keyE = valueE\n" ); assertThat(contentOf(f2)).isEqualTo("" + "keyA = valueA\n" + "keyB = valueB\n" + "keyC = valueC\n" + "keyD = valueD\n" + "keyE = valueE\n" ); }
public void reorderByKey(final FileMatcher fileMatcher, final AttachCommentsTo attachCommentsTo, final Charset charset) { Require.nonNull(fileMatcher); Require.nonNull(attachCommentsTo); Require.nonNull(charset); final Reformatter reformatter= new Reformatter( ReformatOptions.create() .with(charset) .with(attachCommentsTo)); final Set<File> propertyFiles= fileMatcher.findMatchingFiles(); LOGGER.log(Level.INFO, "Reordering entries in the following files: {}", propertyFiles); propertyFiles.stream().forEach(_f -> { final PropertyFile pf= PropertyFile.from(_f, charset); reformatter.reorderByKey(pf); pf.overwrite(_f, APRON_OPTIONS.with(charset)); }); }
KiltReformatter { public void reorderByKey(final FileMatcher fileMatcher, final AttachCommentsTo attachCommentsTo, final Charset charset) { Require.nonNull(fileMatcher); Require.nonNull(attachCommentsTo); Require.nonNull(charset); final Reformatter reformatter= new Reformatter( ReformatOptions.create() .with(charset) .with(attachCommentsTo)); final Set<File> propertyFiles= fileMatcher.findMatchingFiles(); LOGGER.log(Level.INFO, "Reordering entries in the following files: {}", propertyFiles); propertyFiles.stream().forEach(_f -> { final PropertyFile pf= PropertyFile.from(_f, charset); reformatter.reorderByKey(pf); pf.overwrite(_f, APRON_OPTIONS.with(charset)); }); } }
KiltReformatter { public void reorderByKey(final FileMatcher fileMatcher, final AttachCommentsTo attachCommentsTo, final Charset charset) { Require.nonNull(fileMatcher); Require.nonNull(attachCommentsTo); Require.nonNull(charset); final Reformatter reformatter= new Reformatter( ReformatOptions.create() .with(charset) .with(attachCommentsTo)); final Set<File> propertyFiles= fileMatcher.findMatchingFiles(); LOGGER.log(Level.INFO, "Reordering entries in the following files: {}", propertyFiles); propertyFiles.stream().forEach(_f -> { final PropertyFile pf= PropertyFile.from(_f, charset); reformatter.reorderByKey(pf); pf.overwrite(_f, APRON_OPTIONS.with(charset)); }); }  }
KiltReformatter { public void reorderByKey(final FileMatcher fileMatcher, final AttachCommentsTo attachCommentsTo, final Charset charset) { Require.nonNull(fileMatcher); Require.nonNull(attachCommentsTo); Require.nonNull(charset); final Reformatter reformatter= new Reformatter( ReformatOptions.create() .with(charset) .with(attachCommentsTo)); final Set<File> propertyFiles= fileMatcher.findMatchingFiles(); LOGGER.log(Level.INFO, "Reordering entries in the following files: {}", propertyFiles); propertyFiles.stream().forEach(_f -> { final PropertyFile pf= PropertyFile.from(_f, charset); reformatter.reorderByKey(pf); pf.overwrite(_f, APRON_OPTIONS.with(charset)); }); }  void reformat(final FileMatcher fileMatcher, final String formatString, final boolean reformatKeyAndValue, final Charset charset); void reorderByKey(final FileMatcher fileMatcher, final AttachCommentsTo attachCommentsTo, final Charset charset); void reorderByTemplate(final File template, final FileMatcher fileMatcher, final AttachCommentsTo attachCommentsTo, final Charset charset); }
KiltReformatter { public void reorderByKey(final FileMatcher fileMatcher, final AttachCommentsTo attachCommentsTo, final Charset charset) { Require.nonNull(fileMatcher); Require.nonNull(attachCommentsTo); Require.nonNull(charset); final Reformatter reformatter= new Reformatter( ReformatOptions.create() .with(charset) .with(attachCommentsTo)); final Set<File> propertyFiles= fileMatcher.findMatchingFiles(); LOGGER.log(Level.INFO, "Reordering entries in the following files: {}", propertyFiles); propertyFiles.stream().forEach(_f -> { final PropertyFile pf= PropertyFile.from(_f, charset); reformatter.reorderByKey(pf); pf.overwrite(_f, APRON_OPTIONS.with(charset)); }); }  void reformat(final FileMatcher fileMatcher, final String formatString, final boolean reformatKeyAndValue, final Charset charset); void reorderByKey(final FileMatcher fileMatcher, final AttachCommentsTo attachCommentsTo, final Charset charset); void reorderByTemplate(final File template, final FileMatcher fileMatcher, final AttachCommentsTo attachCommentsTo, final Charset charset);  }