diff options
author | Håkon Hallingstad <hakon@yahooinc.com> | 2022-01-11 14:44:59 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@yahooinc.com> | 2022-01-11 14:44:59 +0100 |
commit | b75fc51e5d0f6f43dad8e999273e1754545a647f (patch) | |
tree | 691f11e983bd7119f72a2cca22f29a7d92da8f30 /node-admin/src | |
parent | 30d845367c9018a2f423b612c05b0ecf28c01fb4 (diff) |
Rename to Template::newForm
Diffstat (limited to 'node-admin/src')
4 files changed, 14 insertions, 21 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/IfSection.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/IfSection.java index 6bf2811d72e..8775e764b4f 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/IfSection.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/IfSection.java @@ -9,15 +9,15 @@ import java.util.Optional; /** * @author hakonhall */ -public class IfSection extends Section { +class IfSection extends Section { private final boolean negated; private final String name; private final Cursor nameOffset; private final SectionList ifSections; private final Optional<SectionList> elseSections; - public IfSection(CursorRange range, boolean negated, String name, Cursor nameOffset, - SectionList ifSections, Optional<SectionList> elseSections) { + IfSection(CursorRange range, boolean negated, String name, Cursor nameOffset, + SectionList ifSections, Optional<SectionList> elseSections) { super(range); this.negated = negated; this.name = name; diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/ListSection.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/ListSection.java index aede0647683..bc68cf96153 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/ListSection.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/template/ListSection.java @@ -8,9 +8,6 @@ import java.util.ArrayList; import java.util.List; /** - * Represents a template list section, to be replaced by any number of body form elements. - * - * @see Template * @author hakonhall */ class ListSection extends Section { 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 c5b752f2d6e..344424c7946 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 @@ -19,13 +19,9 @@ package com.yahoo.vespa.hosted.node.admin.task.util.template; * <p>If the directive's end delimiter (}) is preceded by a "-" char, then any newline (\n) * immediately following the end delimiter is removed.</p> * - * <p>To use the template, <b>Instantiate</b> it to get a form ({@link #instantiate()}), fill it (e.g. + * <p>To use the template create a form ({@link #newForm()}), fill the form (e.g. * {@link Form#set(String, String) Form.set()}), and render the String ({@link Form#render()}).</p> * - * <p>A form (like a template) has direct sections, and indirect sections in the body of direct list - * sections (recursively). The variables that can be set for a form, are the variables defined in - * either direct or indirect variable sections.</p> - * * @see Form * @see TemplateFile * @author hakonhall @@ -43,6 +39,6 @@ public class Template { this.form = form; } - public Form instantiate() { return form.copy(); } + public Form newForm() { return form.copy(); } } diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/template/TemplateFileTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/template/TemplateFileTest.java index 807849bbdb6..b73e50180c6 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/template/TemplateFileTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/task/util/template/TemplateFileTest.java @@ -86,8 +86,8 @@ class TemplateFileTest { @Test void verifyIfSection() { Template template = Template.from("Hello%{if cond} world%{end}!"); - assertEquals("Hello world!", template.instantiate().set("cond", true).render()); - assertEquals("Hello!", template.instantiate().set("cond", false).render()); + assertEquals("Hello world!", template.newForm().set("cond", true).render()); + assertEquals("Hello!", template.newForm().set("cond", false).render()); } @Test @@ -98,18 +98,18 @@ class TemplateFileTest { "list: %{list formname}element%{end}\n" + "%{end-}\n"); - assertEquals("", template.instantiate().set("cond", false).render()); + assertEquals("", template.newForm().set("cond", false).render()); assertEquals("var: varvalue\n" + "if: \n" + "list: \n", - template.instantiate() + template.newForm() .set("cond", true) .set("varname", "varvalue") .set("inner", true) .render()); - Form form = template.instantiate() + Form form = template.newForm() .set("cond", true) .set("varname", "varvalue") .set("inner", false); @@ -127,15 +127,15 @@ class TemplateFileTest { "%{else-}\n" + "else body\n" + "%{end-}\n"); - assertEquals("if body\n", template.instantiate().set("cond", true).render()); - assertEquals("else body\n", template.instantiate().set("cond", false).render()); + assertEquals("if body\n", template.newForm().set("cond", true).render()); + assertEquals("else body\n", template.newForm().set("cond", false).render()); } private Form getForm(String filename) { - return TemplateFile.read(Path.of("src/test/resources/" + filename)).instantiate(); + return TemplateFile.read(Path.of("src/test/resources/" + filename)).newForm(); } private Form makeForm(String templateText) { - return Template.from(templateText).instantiate(); + return Template.from(templateText).newForm(); } }
\ No newline at end of file |