From c7a69dbf88d6645ac854e2e2f722420e3ba8405e Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Thu, 21 Aug 2014 17:51:52 +0200 Subject: [PATCH] [New] Added convenience method Locator.newLocatorBuilder(String...) --- src/main/java/li/strolch/model/Locator.java | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/li/strolch/model/Locator.java b/src/main/java/li/strolch/model/Locator.java index 0dd9f093c..5e60f9852 100644 --- a/src/main/java/li/strolch/model/Locator.java +++ b/src/main/java/li/strolch/model/Locator.java @@ -274,6 +274,18 @@ public class Locator { return new Locator(path); } + /** + * Creates a new {@link LocatorBuilder} instance and appends the given elements to it + * + * @param path + * the first element on the {@link Locator} + * + * @return a new {@link LocatorBuilder} instance with the given root element tag as the first element + */ + public static LocatorBuilder newBuilder(String... path) { + return new LocatorBuilder().append(path); + } + /** * Creates a new {@link LocatorBuilder} instance and appends the given root element tag to it * @@ -303,6 +315,21 @@ public class Locator { this.pathElements = new ArrayList(); } + /** + * Append the given elements to the path + * + * @param path + * the path elements to add + * + * @return this instance for chaining + */ + public LocatorBuilder append(String... path) { + for (String element : path) { + this.pathElements.add(element); + } + return this; + } + /** * Append an element to the path *