polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [1/2] polygene-java git commit: Leveraging computeIfAbsent() for less code.
Date Tue, 28 Mar 2017 07:47:55 GMT
Repository: polygene-java
Updated Branches:
  refs/heads/develop 994905196 -> c48230e79


Leveraging computeIfAbsent() for less code.


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

Branch: refs/heads/develop
Commit: 2585085930c54766259e7b8ea386847c803d9934
Parents: cfd3862
Author: niclas <niclas@spicter.com>
Authored: Fri Mar 24 17:14:24 2017 +0800
Committer: niclas <niclas@spicter.com>
Committed: Fri Mar 24 17:14:24 2017 +0800

----------------------------------------------------------------------
 .../runtime/bootstrap/AssemblyHelper.java       | 24 ++++----------------
 1 file changed, 4 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/25850859/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/AssemblyHelper.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/AssemblyHelper.java
b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/AssemblyHelper.java
index 1263e29..b456a1e 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/AssemblyHelper.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/bootstrap/AssemblyHelper.java
@@ -91,13 +91,7 @@ public class AssemblyHelper
 
     protected FragmentClassLoader getModifierClassLoader( ClassLoader classLoader )
     {
-        FragmentClassLoader cl = modifierClassLoaders.get( classLoader );
-        if( cl == null )
-        {
-            cl = instantiateFragmentClassLoader( classLoader );
-            modifierClassLoaders.put( classLoader, cl );
-        }
-        return cl;
+        return modifierClassLoaders.computeIfAbsent( classLoader, k -> instantiateFragmentClassLoader(
classLoader ) );
     }
 
     protected FragmentClassLoader instantiateFragmentClassLoader( ClassLoader classLoader
)
@@ -107,12 +101,7 @@ public class AssemblyHelper
 
     public boolean appliesTo( Class<?> fragmentClass, Method method, Iterable<Class<?>>
types, Class<?> mixinClass )
     {
-        AppliesToFilter appliesToFilter = appliesToInstances.get( fragmentClass );
-        if( appliesToFilter == null )
-        {
-            appliesToFilter = createAppliesToFilter( fragmentClass );
-            appliesToInstances.put( fragmentClass, appliesToFilter );
-        }
+        AppliesToFilter appliesToFilter = appliesToInstances.computeIfAbsent( fragmentClass,
k -> createAppliesToFilter( fragmentClass ) );
         for( Class<?> compositeType : types )
         {
             if( appliesToFilter.appliesTo( method, mixinClass, compositeType, fragmentClass
) )
@@ -202,13 +191,8 @@ public class AssemblyHelper
                               Type valueType
     )
     {
-        ConstraintDeclaration constraintDeclaration = constraintDeclarations.get( constraint
);
-        if( constraintDeclaration == null )
-        {
-            constraintDeclaration = new ConstraintDeclaration( constraint );
-            constraintDeclarations.put( constraint, constraintDeclaration );
-        }
-
+        ConstraintDeclaration constraintDeclaration =
+            constraintDeclarations.computeIfAbsent( constraint, k -> new ConstraintDeclaration(
constraint ) );
         return constraintDeclaration.appliesTo( annotationType, valueType );
     }
 }


Mime
View raw message