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 2016/07/19 10:47:27 UTC

incubator-tamaya git commit: - Minimalized API.

Repository: incubator-tamaya
Updated Branches:
  refs/heads/tamaya-next 13fd04cc4 -> a72893099


- Minimalized API.


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

Branch: refs/heads/tamaya-next
Commit: a728930996d82400530e29af387062e4658aa677
Parents: 13fd04c
Author: anatole <an...@apache.org>
Authored: Tue Jul 19 12:47:15 2016 +0200
Committer: anatole <an...@apache.org>
Committed: Tue Jul 19 12:47:15 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/tamaya/Configuration.java   | 126 +++++++++----------
 .../apache/tamaya/ConfigurationProvider.java    |   7 +-
 2 files changed, 63 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a7289309/code/api/src/main/java/org/apache/tamaya/Configuration.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/Configuration.java b/code/api/src/main/java/org/apache/tamaya/Configuration.java
index 580ec5e..188a3ff 100644
--- a/code/api/src/main/java/org/apache/tamaya/Configuration.java
+++ b/code/api/src/main/java/org/apache/tamaya/Configuration.java
@@ -20,7 +20,6 @@ package org.apache.tamaya;
 
 import java.util.Map;
 
-
 /**
  * <p>A configuration models a aggregated set of current properties, identified by
  * a unique key.
@@ -54,71 +53,22 @@ public interface Configuration {
      * @param defaultValue value to be returned, if no value is present.
      * @return the property's keys.
      */
-    default String getOrDefault(String key, final String defaultValue){
-        return getOrDefault(key, () -> defaultValue);
-    }
+    String getOrDefault(String key, final String defaultValue);
 
-    /**
-     * Access a property providing a value supplier called, if no configured value is available.
-     *
-     * @param key the property's key, not null.
-     * @param defaultValueSupplier value supplier to be called, if no value is present.
-     * @return the property value.
-     */
-    default String getOrDefault(String key, Supplier<String> defaultValueSupplier){
-        String value = get(key);
-        if(value==null){
-            return defaultValueSupplier.supply();
-        }
-        return value;
-    }
-
-    /**
-     * Access a typed property providing a conversion.
-     *
-     * @param key the property's key, not null.
-     * @param conversion the value conversion, called if a configured value is present for the given key,
-     *                   not null.
-     * @return the property value, or null, if no such value has been found.
-     */
-    default <T> T get(String key, Function<String,T> conversion){
-        String value = get(key);
-        if(value!=null){
-            return conversion.apply(value);
-        }
-        return null;
-    }
-
-    /**
-     * Access a typed property providing a conversion and a default value.
-     *
-     * @param key the property's key, not null.
-     * @param conversion the value conversion, called if a configured value is present for the given key,
-     *                   not null.
-     * @param defaultValue the default value to be returned, if no configured value has been found, including
-     *                     {@code null}.
-     * @return the property value, or null, if no such value has been found.
-     */
-    default <T> T getOrDefault(String key, Function<String,T> conversion, final T defaultValue){
-        return getOrDefault(key, conversion, () -> defaultValue);
-    }
-
-    /**
-     * Access a typed property providing a conversion and a default value supplier.
-     *
-     * @param key the property's key, not null.
-     * @param conversion the value conversion, called if a configured value is present for the given key,
-     *                   not null.
-     * @param defaultValueSupplier the default value supplier to be called, if no configured value has been found..
-     * @return the property value, or null, if no such value has been found.
-     */
-    default <T> T getOrDefault(String key, Function<String,T> conversion, Supplier<T> defaultValueSupplier){
-        String value = get(key);
-        if(value!=null){
-            return conversion.apply(value);
-        }
-        return defaultValueSupplier.supply();
-    }
+//    /**
+//     * Access a property providing a value supplier called, if no configured value is available.
+//     *
+//     * @param key the property's key, not null.
+//     * @param defaultValueSupplier value supplier to be called, if no value is present.
+//     * @return the property value.
+//     */
+//    default String getOrDefault(String key, Supplier<String> defaultValueSupplier){
+//        String value = get(key);
+//        if(value==null){
+//            return defaultValueSupplier.supply();
+//        }
+//        return value;
+//    }
 
     /**
      * Access all currently known configuration properties as a full {@code Map<String,String>}.
@@ -126,4 +76,50 @@ public interface Configuration {
      */
     Map<String,String> getProperties();
 
+//    /**
+//     * Access a typed property providing a conversion.
+//     *
+//     * @param key the property's key, not null.
+//     * @param conversion the value conversion, called if a configured value is present for the given key,
+//     *                   not null.
+//     * @return the property value, or null, if no such value has been found.
+//     */
+//    default <T> T get(String key, Function<String,T> conversion){
+//        String value = get(key);
+//        if(value!=null){
+//            return conversion.apply(value);
+//        }
+//        return null;
+//    }
+//
+//    /**
+//     * Access a typed property providing a conversion and a default value.
+//     *
+//     * @param key the property's key, not null.
+//     * @param conversion the value conversion, called if a configured value is present for the given key,
+//     *                   not null.
+//     * @param defaultValue the default value to be returned, if no configured value has been found, including
+//     *                     {@code null}.
+//     * @return the property value, or null, if no such value has been found.
+//     */
+//    default <T> T getOrDefault(String key, Function<String,T> conversion, final T defaultValue){
+//        return getOrDefault(key, conversion, () -> defaultValue);
+//    }
+//    /**
+//     * Access a typed property providing a conversion and a default value supplier.
+//     *
+//     * @param key the property's key, not null.
+//     * @param conversion the value conversion, called if a configured value is present for the given key,
+//     *                   not null.
+//     * @param defaultValueSupplier the default value supplier to be called, if no configured value has been found..
+//     * @return the property value, or null, if no such value has been found.
+//     */
+//    default <T> T getOrDefault(String key, Function<String,T> conversion, Supplier<T> defaultValueSupplier){
+//        String value = get(key);
+//        if(value!=null){
+//            return conversion.apply(value);
+//        }
+//        return defaultValueSupplier.supply();
+//    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a7289309/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java b/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
index af4c3e7..f0f2298 100644
--- a/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
+++ b/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
@@ -29,12 +29,13 @@ import java.util.logging.Logger;
 /**
  * Static access to the {@link Configuration} for the very application.
  */
-public abstract class ConfigurationProvider {
+public final class ConfigurationProvider {
 
     private static final Logger LOG = Logger.getLogger("ConfigurationProvider");
 
     private static final Configuration INSTANCE = loadConfiguration();
 
+    private ConfigurationProvider(){}
 
     private static Configuration loadConfiguration() {
         for(Configuration config: ServiceLoader.load(Configuration.class)){
@@ -83,10 +84,6 @@ public abstract class ConfigurationProvider {
         }
     }
 
-    protected ConfigurationProvider() {
-        // just to prevent initialisation
-    }
-
     /**
      * Access the current configuration.
      * @return the configuration.