diff options
author | Håkon Hallingstad <hakon@yahooinc.com> | 2022-01-12 08:56:17 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@yahooinc.com> | 2022-01-12 08:56:17 +0100 |
commit | 24a3202a133636af279931491096f4cdce339ffc (patch) | |
tree | f5328d9b37913128367fe11a66f44bf0851c1218 /node-admin/src/main | |
parent | c68d279f66031cb1a599589a8a346200f3514178 (diff) |
Merge TemplateFile into Template
Diffstat (limited to 'node-admin/src/main')
2 files changed, 8 insertions, 22 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/Template.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/Template.java index 77d50a392c8..da3d4eef03f 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/Template.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/Template.java @@ -1,8 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.node.admin.task.util.template; +import com.yahoo.vespa.hosted.node.admin.task.util.file.UnixPath; import com.yahoo.vespa.hosted.node.admin.task.util.text.CursorRange; +import java.nio.file.Path; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -29,7 +31,6 @@ import java.util.Optional; * * <p>To reuse a template, create the template and work on snapshots of that ({@link #snapshot()}).</p> * - * @see TemplateFile * @author hakonhall */ public class Template { @@ -40,8 +41,13 @@ public class Template { private final Map<String, String> values = new HashMap<>(); private final Map<String, ListSection> lists; - public static Template from(String text) { return from(text, new TemplateDescriptor()); } + public static Template at(Path path) { return at(path, new TemplateDescriptor()); } + public static Template at(Path path, TemplateDescriptor descriptor) { + String content = new UnixPath(path).readUtf8File(); + return Template.from(content, descriptor); + } + public static Template from(String text) { return from(text, new TemplateDescriptor()); } public static Template from(String text, TemplateDescriptor descriptor) { return TemplateParser.parse(text, descriptor).template(); } diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/TemplateFile.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/TemplateFile.java deleted file mode 100644 index 0c1a26f4f65..00000000000 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/TemplateFile.java +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.node.admin.task.util.template; - -import com.yahoo.vespa.hosted.node.admin.task.util.file.UnixPath; - -import java.nio.file.Path; - -/** - * Parses a template file, see {@link Template} for details. - * - * @author hakonhall - */ -public class TemplateFile { - public static Template read(Path path) { return read(path, new TemplateDescriptor()); } - - public static Template read(Path path, TemplateDescriptor descriptor) { - String content = new UnixPath(path).readUtf8File(); - return Template.from(content, descriptor); - } -} |