tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ple...@apache.org
Subject [11/50] [abbrv] incubator-tamaya-sandbox git commit: Added collection support.
Date Sun, 25 Sep 2016 21:23:59 GMT
Added collection support.


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

Branch: refs/heads/master
Commit: 4ac2dd723edbea5809cbe0042ecb0deadde315d4
Parents: 1a7b54d
Author: anatole <anatole@apache.org>
Authored: Sat May 9 00:57:35 2015 +0200
Committer: anatole <anatole@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-sandbox/blob/4ac2dd72/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java b/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
index dfe821b..799b114 100644
--- a/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
+++ b/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)


Mime
View raw message