deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject [2/2] git commit: DELTASPIKE-378 unify handling of defaultValue
Date Sun, 16 Jun 2013 08:47:45 GMT
DELTASPIKE-378 unify handling of defaultValue


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

Branch: refs/heads/master
Commit: f83662f51e2bbcb77a760d23695dda66fdfb6a11
Parents: d99215c
Author: Mark Struberg <struberg@apache.org>
Authored: Thu Jun 13 09:07:43 2013 +0200
Committer: Mark Struberg <struberg@apache.org>
Committed: Sun Jun 16 10:47:21 2013 +0200

----------------------------------------------------------------------
 .../core/api/config/ConfigResolver.java         | 38 ++++++++++----------
 1 file changed, 18 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f83662f5/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
index 6b3ada2..b7802a3 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
@@ -108,15 +108,9 @@ public final class ConfigResolver
      */
     public static String getPropertyValue(String key, String defaultValue)
     {
-        String configuredValue = getPropertyValue(key);
-        if (configuredValue == null)
-        {
-            LOG.log(Level.FINE, "no configured value found for key {0}, using default value
{1}.",
-                    new Object[]{key, defaultValue});
+        String value = getPropertyValue(key);
 
-            configuredValue = defaultValue;
-        }
-        return configuredValue;
+        return fallbackToDefaultIfEmpty(key, value, defaultValue);
     }
 
     /**
@@ -189,12 +183,7 @@ public final class ConfigResolver
     {
         String value = getProjectStageAwarePropertyValue(key);
 
-        if (value == null || value.length() == 0)
-        {
-            value = defaultValue;
-        }
-
-        return value;
+        return fallbackToDefaultIfEmpty(key, value, defaultValue);
     }
 
     /**
@@ -263,12 +252,7 @@ public final class ConfigResolver
     {
         String value = getPropertyAwarePropertyValue(key, property);
 
-        if (value == null || value.length() == 0)
-        {
-            value = defaultValue;
-        }
-
-        return value;
+        return fallbackToDefaultIfEmpty(key, value, defaultValue);
     }
 
     /**
@@ -402,4 +386,18 @@ public final class ConfigResolver
         return projectStage;
     }
 
+    private static String fallbackToDefaultIfEmpty(String key, String value, String defaultValue)
+    {
+        if (value == null || value.length() == 0)
+        {
+            LOG.log(Level.FINE, "no configured value found for key {0}, using default value
{1}.",
+                    new Object[]{key, defaultValue});
+
+            return defaultValue;
+        }
+
+        return value;
+    }
+
+
 }


Mime
View raw message