polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [14/34] zest-java git commit: Kent suggested that if multiple Concerns/SideEffects of same type are found, then remove the previous one and add the new one at the end.
Date Thu, 14 Apr 2016 06:13:20 GMT
Kent suggested that if multiple Concerns/SideEffects of same type are found, then remove the
previous one and add the new one at the end.


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

Branch: refs/heads/develop
Commit: 81561b096a354b5b96b47f77e2d7e2f582a36dfe
Parents: a5be013
Author: Niclas Hedhman <niclas@hedhman.org>
Authored: Wed Dec 16 15:22:36 2015 +0800
Committer: Niclas Hedhman <niclas@hedhman.org>
Committed: Wed Dec 16 15:22:36 2015 +0800

----------------------------------------------------------------------
 .../bootstrap/CompositeAssemblyImpl.java        | 31 +++++++++-----------
 1 file changed, 14 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/81561b09/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
index c7308f7..f1842b1 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/bootstrap/CompositeAssemblyImpl.java
@@ -590,7 +590,7 @@ public abstract class CompositeAssemblyImpl
         concernClasses.forEach( concern -> {
             if( helper.appliesTo( concern, method, types, mixinClass ) )
             {
-                addConcernIfNotExists( concernsFor, helper.getConcernModel( concern ) );
+                addConcernOrRepositionIfExists( concernsFor, helper.getConcernModel( concern
) );
             }
             else
             {
@@ -602,7 +602,7 @@ public abstract class CompositeAssemblyImpl
                         Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes()
);
                         if( helper.appliesTo( concern, mixinMethod, types, mixinClass ) )
                         {
-                            addConcernIfNotExists( concernsFor, helper.getConcernModel( concern
) );
+                            addConcernOrRepositionIfExists( concernsFor, helper.getConcernModel(
concern ) );
                         }
                     }
                     catch( NoSuchMethodException e )
@@ -625,7 +625,7 @@ public abstract class CompositeAssemblyImpl
                     if( helper.appliesTo( concern, method, types, mixinClass ) )
                     {
                         ConcernModel concernModel = helper.getConcernModel( concern );
-                        addConcernIfNotExists( concernsFor, concernModel );
+                        addConcernOrRepositionIfExists( concernsFor, concernModel );
                     }
                 }
             }
@@ -641,12 +641,11 @@ public abstract class CompositeAssemblyImpl
         }
     }
 
-    private void addConcernIfNotExists( List<ConcernModel> concernsFor, ConcernModel
concernModel )
+    private void addConcernOrRepositionIfExists( List<ConcernModel> concernsFor, ConcernModel
concernModel )
     {
-        if( !concernsFor.contains( concernModel ) )
-        {
-            concernsFor.add( concernModel );
-        }
+        // This remove/add is to allow re-ordering of the concerns
+        concernsFor.remove( concernModel );
+        concernsFor.add( concernModel );
     }
 
     private SideEffectsModel sideEffectsFor( Method method,
@@ -659,7 +658,7 @@ public abstract class CompositeAssemblyImpl
             SideEffectModel sideEffectModel = helper.getSideEffectModel( sideEffect );
             if( helper.appliesTo( sideEffect, method, types, mixinClass ) )
             {
-                addSideEffectIfNotExists( sideEffectsFor, sideEffectModel );
+                addSideEffectOrRepositionIfExists( sideEffectsFor, sideEffectModel );
             }
             else
             {
@@ -671,7 +670,7 @@ public abstract class CompositeAssemblyImpl
                         Method mixinMethod = mixinClass.getMethod( method.getName(), method.getParameterTypes()
);
                         if( helper.appliesTo( sideEffect, mixinMethod, types, mixinClass
) )
                         {
-                            addSideEffectIfNotExists( sideEffectsFor, sideEffectModel );
+                            addSideEffectOrRepositionIfExists( sideEffectsFor, sideEffectModel
);
                         }
                     }
                     catch( NoSuchMethodException e )
@@ -694,13 +693,12 @@ public abstract class CompositeAssemblyImpl
                     if( helper.appliesTo( sideEffect, method, types, mixinClass ) )
                     {
                         SideEffectModel sideEffectModel = helper.getSideEffectModel( sideEffect
);
-                        addSideEffectIfNotExists( sideEffectsFor, sideEffectModel );
+                        addSideEffectOrRepositionIfExists( sideEffectsFor, sideEffectModel
);
                     }
                 }
             }
         }
 
-
         if( sideEffectsFor.isEmpty() )
         {
             return SideEffectsModel.EMPTY_SIDEEFFECTS;
@@ -711,12 +709,11 @@ public abstract class CompositeAssemblyImpl
         }
     }
 
-    private void addSideEffectIfNotExists( List<SideEffectModel> sideEffectsFor, SideEffectModel
sideEffectModel )
+    private void addSideEffectOrRepositionIfExists( List<SideEffectModel> sideEffectsFor,
SideEffectModel sideEffectModel )
     {
-        if( !sideEffectsFor.contains( sideEffectModel ) )
-        {
-            sideEffectsFor.add( sideEffectModel );
-        }
+        // This add/remove is to allow reording of SideEffects.
+        sideEffectsFor.remove( sideEffectModel );
+        sideEffectsFor.add( sideEffectModel );
     }
 
     @SuppressWarnings( "unchecked" )


Mime
View raw message