@Test public void testReorder_multilineProperties() throws IOException { final Path propertiesRootDirectory= this.tmpFolder.getRoot().toPath(); final File f1= createI18nBundle(propertiesRootDirectory, "" + "key\\ \\\n" + " 2\\\n" + " = value \\\n" + " 2\n" + "\n" + " # some comment\n" + "key\\ \\\n" + " 1\\\n" + " = value \\\n" + " 1\n" + "key\\ \\\n" + " 3\\\n" + " = value \\\n" + " 3\n" ); final FileMatcher fileMatcher= new FileMatcher(propertiesRootDirectory, new String[]{"**/*.properties"}, new String[]{""}); new KiltReformatter() .reorderByKey(fileMatcher, AttachCommentsTo.ORIG_LINE, UTF_8); assertThat(contentOf(f1)).isEqualTo("" + "key\\ \\\n" + " 1\\\n" + " = value \\\n" + " 1\n" + "\n" + " # some comment\n" + "key\\ \\\n" + " 2\\\n" + " = value \\\n" + " 2\n" + "key\\ \\\n" + " 3\\\n" + " = value \\\n" + " 3\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);  }