tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [2/5] incubator-tamaya git commit: TAMAYA-212: Rendered default comparators into singletons.
Date Thu, 22 Dec 2016 21:19:26 GMT
TAMAYA-212: Rendered default comparators into singletons.


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

Branch: refs/heads/master
Commit: 7796303ddffd590a8ff14d3091278ef540ba041b
Parents: b31278a
Author: anatole <anatole@apache.org>
Authored: Wed Dec 21 16:49:15 2016 +0100
Committer: anatole <anatole@apache.org>
Committed: Wed Dec 21 16:49:15 2016 +0100

----------------------------------------------------------------------
 .../core/internal/DefaultConfigurationContextBuilder.java |  5 +----
 .../tamaya/core/internal/PropertyFilterComparator.java    |  3 +++
 .../tamaya/core/internal/PropertySourceComparator.java    |  3 +++
 .../core/internal/PriorityServiceComparatorTest.java      | 10 ++++------
 4 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7796303d/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
index b3dcc82..2e34842 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
@@ -48,9 +48,6 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
 
     private static final Logger LOG = Logger.getLogger(DefaultConfigurationContextBuilder.class.getName());
 
-    public static final Comparator<PropertySource> DEFAULT_PROPERTYSOURCE_COMPARATOR
= new PropertySourceComparator();
-    public static final Comparator<?> DEFAULT_PROPERTYFILTER_COMPARATOR = new PriorityServiceComparator();
-
     List<PropertyFilter> propertyFilters = new ArrayList<>();
     List<PropertySource> propertySources = new ArrayList<>();
     PropertyValueCombinationPolicy combinationPolicy =
@@ -139,7 +136,7 @@ public class DefaultConfigurationContextBuilder implements ConfigurationContextB
                 ServiceContextManager.getServiceContext().getServices(PropertySourceProvider.class)){
                 propertySources.addAll(provider.getPropertySources());
         }
-        Collections.sort(propertySources, DEFAULT_PROPERTYSOURCE_COMPARATOR);
+        Collections.sort(propertySources, PropertySourceComparator.getInstance());
         return addPropertySources(propertySources);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7796303d/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFilterComparator.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFilterComparator.java
b/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFilterComparator.java
index e0bd8e0..96779df 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFilterComparator.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFilterComparator.java
@@ -33,6 +33,9 @@ public class PropertyFilterComparator implements Comparator<PropertyFilter>,
Ser
 
     private static final PropertyFilterComparator INSTANCE = new PropertyFilterComparator();
 
+    /** Singleton constructor. */
+    private PropertyFilterComparator(){}
+
     /**
      * Get the shared instance of the comparator.
      * @return the shared instance, never null.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7796303d/code/core/src/main/java/org/apache/tamaya/core/internal/PropertySourceComparator.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertySourceComparator.java
b/code/core/src/main/java/org/apache/tamaya/core/internal/PropertySourceComparator.java
index f686ee3..0b46f1c 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertySourceComparator.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/PropertySourceComparator.java
@@ -32,6 +32,9 @@ public class PropertySourceComparator implements Comparator<PropertySource>,
Ser
 
     private static final PropertySourceComparator INSTANCE = new PropertySourceComparator();
 
+    /** Singleton constructor. */
+    private PropertySourceComparator(){}
+
     /**
      * Get the shared instance of the comparator.
      * @return the shared instance, never null.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7796303d/code/core/src/test/java/org/apache/tamaya/core/internal/PriorityServiceComparatorTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/PriorityServiceComparatorTest.java
b/code/core/src/test/java/org/apache/tamaya/core/internal/PriorityServiceComparatorTest.java
index e08c8b0..1b1425b 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/PriorityServiceComparatorTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/PriorityServiceComparatorTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tamaya.core.internal;
 
-import org.apache.tamaya.core.propertysource.EnvironmentPropertySource;
 import org.apache.tamaya.core.propertysource.SystemPropertySource;
 import org.junit.Test;
 
@@ -31,14 +30,13 @@ import static org.junit.Assert.*;
  */
 public class PriorityServiceComparatorTest {
 
-    private PriorityServiceComparator comp = new PriorityServiceComparator();
 
     @Test
     public void compare() throws Exception {
-        assertTrue(comp.compare("a", "b")==0);
-        assertTrue(comp.compare(getClass(), getClass())==0);
-        assertTrue(comp.compare(new A(), new SystemPropertySource())==-1);
-        assertTrue(comp.compare(new SystemPropertySource(), new A())==1);
+        assertTrue(PriorityServiceComparator.getInstance().compare("a", "b")==0);
+        assertTrue(PriorityServiceComparator.getInstance().compare(getClass(), getClass())==0);
+        assertTrue(PriorityServiceComparator.getInstance().compare(new A(), new SystemPropertySource())==-1);
+        assertTrue(PriorityServiceComparator.getInstance().compare(new SystemPropertySource(),
new A())==1);
     }
 
     @Priority(100)


Mime
View raw message