From 8cdb9b19ea421c7373f4a086a28cb3c90c2b53c5 Mon Sep 17 00:00:00 2001 From: toby Date: Tue, 17 Apr 2018 15:07:27 +0200 Subject: Keep editor javadoc for files --- .../vespa/hosted/node/admin/task/util/file/Editor.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java index 3d4dbcca0e6..ebc432ccd5f 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java @@ -31,21 +31,25 @@ public class Editor { private final String name; private final LineEditor editor; + /** + * Read the file which must be encoded in UTF-8, use the LineEditor to edit it, + * and any modifications were done write it back and return true. + */ public Editor(Path path, LineEditor editor) { this(path.toString(), () -> uncheck(() -> Files.readAllLines(path, ENCODING)), - (newLines) -> uncheck(() -> Files.write(path, newLines, ENCODING)), + (newLines) -> uncheck(() -> Files.write(path, newLines, ENCODING)), editor); } /** - * @param name The name of what is being edited - used in logging + * @param name The name of what is being edited - used in logging * @param supplier Supplies the editor with a list of lines to edit * @param consumer Consumes the lines to presist if any changes is detected - * @param editor The line operations to execute on the lines supplied + * @param editor The line operations to execute on the lines supplied */ public Editor(String name, - Supplier> supplier, + Supplier> supplier, Consumer> consumer, LineEditor editor) { this.supplier = supplier; @@ -76,7 +80,8 @@ public class Editor { case NONE: newLines.add(line); break; - default: throw new IllegalArgumentException("Unknown EditType " + edit.getType()); + default: + throw new IllegalArgumentException("Unknown EditType " + edit.getType()); } if (!edit.appendLines().isEmpty()) { -- cgit v1.2.3