You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2015/05/09 01:13:27 UTC

[4/6] incubator-tamaya git commit: Added collection support.

Added collection support.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/6645aa20
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/6645aa20
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/6645aa20

Branch: refs/heads/master
Commit: 6645aa2066a2635749a57a6f6882f79da2476daa
Parents: 0dfe701
Author: anatole <an...@apache.org>
Authored: Sat May 9 00:57:35 2015 +0200
Committer: anatole <an...@apache.org>
Committed: Sat May 9 00:57:35 2015 +0200

----------------------------------------------------------------------
 .../tamaya/builder/ConfigurationBuilder.java    | 33 ++++++++++++++++++--
 1 file changed, 30 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6645aa20/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java b/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
index dfe821b..799b114 100644
--- a/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
+++ b/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
@@ -149,7 +149,6 @@ public class ConfigurationBuilder {
         } catch (IOException e) {
             throw new ConfigException("Failed to read " + url.toString(), e);
         }
-
         return this;
     }
 
@@ -187,7 +186,7 @@ public class ConfigurationBuilder {
      * @see org.apache.tamaya.format.ConfigurationFormat
      * @see org.apache.tamaya.format.ConfigurationFormats#getFormats()
      */
-    public ConfigurationBuilder addPropertySource(URL... urls) {
+    public ConfigurationBuilder addPropertySources(URL... urls) {
         Stream.of(Arrays.asList(urls))
               .flatMap(Collection::stream)
               .filter(entry -> entry != null)
@@ -197,6 +196,34 @@ public class ConfigurationBuilder {
         return this;
     }
 
+    /**
+     * Adds one or more resources with properties in an arbitrary format
+     * to the configuration to be build.
+     *
+     * <p>If a specific format is supported depends on the available
+     * {@link org.apache.tamaya.format.ConfigurationFormat} implementations.</p>
+     *
+     *<pre>{@code URL first = new URL("file:/etc/service/config.json");
+     * URL second = new URL("file:/etc/defaults/values.properties");
+     *
+     * builder.addPropertySources(first, second);}
+     *</pre>
+     *
+     * @param urls list of resources with properties for the configuration to be
+     *             build.
+     *
+     * @return the builder instance currently used
+     *
+     * @see org.apache.tamaya.format.ConfigurationFormat
+     * @see org.apache.tamaya.format.ConfigurationFormats#getFormats()
+     */
+    public ConfigurationBuilder addPropertySources(Collection<URL> urls) {
+        urls.stream()
+                .filter(entry -> entry != null)
+                .forEach(this::addPropertySource);
+        return this;
+    }
+
 
     /**
      * Adds one or more resources with properties in an arbitrary format
@@ -217,7 +244,7 @@ public class ConfigurationBuilder {
      * @see org.apache.tamaya.format.ConfigurationFormat
      * @see org.apache.tamaya.format.ConfigurationFormats#getFormats()
      */
-    public ConfigurationBuilder addPropertySource(String... urls) {
+    public ConfigurationBuilder addPropertySources(String... urls) {
         Stream.of(Arrays.asList(urls))
               .flatMap(Collection::stream)
               .filter(entry -> entry != null)