felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1725647 [2/2] - in /felix/sandbox/pderop/dependencymanager-lambda: ./ org.apache.felix.dependencymanager.lambda.itest/src/org/apache/felix/dm/builder/lambda/itest/ org.apache.felix.dependencymanager.lambda.samples/src/org/apache/felix/depe...
Date Tue, 19 Jan 2016 23:00:49 GMT
Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ServiceAspectBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ServiceAspectBuilderImpl.java?rev=1725647&r1=1725646&r2=1725647&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ServiceAspectBuilderImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ServiceAspectBuilderImpl.java
Tue Jan 19 23:00:49 2016
@@ -2,8 +2,6 @@ package org.apache.felix.dm.builder.lamb
 
 import java.util.Objects;
 import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.Supplier;
 
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
@@ -19,7 +17,7 @@ public class ServiceAspectBuilderImpl<T>
     private String m_aspectFilter;
     private int m_aspectRanking;
     private boolean m_autoAdd = true;
-    private Consumer<ComponentBuilder> m_compBuilder = (componentBuilder -> {});
+    private Consumer<ComponentBuilder<?>> m_compBuilder = (componentBuilder ->
{});
 
     public ServiceAspectBuilderImpl(DependencyManager dm, Class<T> type) {
         super(type);
@@ -28,7 +26,7 @@ public class ServiceAspectBuilderImpl<T>
     }
 
     @Override
-    public void andThenBuild(Consumer<ComponentBuilder> after) {
+    public void andThenBuild(Consumer<ComponentBuilder<?>> after) {
         m_compBuilder = m_compBuilder.andThen(after);        
     }
 

Modified: felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ServiceCallbacksBuilderImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ServiceCallbacksBuilderImpl.java?rev=1725647&r1=1725646&r2=1725647&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ServiceCallbacksBuilderImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager-lambda/org.apache.felix.dependencymanager.lambda/src/org/apache/felix/dm/builder/lambda/impl/ServiceCallbacksBuilderImpl.java
Tue Jan 19 23:00:49 2016
@@ -4,20 +4,17 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.stream.Stream;
 
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.builder.lambda.Cb;
 import org.apache.felix.dm.builder.lambda.Functions.CbComponent;
-import org.apache.felix.dm.builder.lambda.Functions.CbComponentDictServiceDictService;
-import org.apache.felix.dm.builder.lambda.Functions.CbComponentMapServiceMapService;
 import org.apache.felix.dm.builder.lambda.Functions.CbComponentRef;
 import org.apache.felix.dm.builder.lambda.Functions.CbComponentRefService;
 import org.apache.felix.dm.builder.lambda.Functions.CbComponentRefServiceRefService;
 import org.apache.felix.dm.builder.lambda.Functions.CbComponentService;
 import org.apache.felix.dm.builder.lambda.Functions.CbComponentServiceService;
-import org.apache.felix.dm.builder.lambda.Functions.CbDictServiceDictService;
-import org.apache.felix.dm.builder.lambda.Functions.CbMapServiceMapService;
 import org.apache.felix.dm.builder.lambda.Functions.CbRef;
 import org.apache.felix.dm.builder.lambda.Functions.CbRefService;
 import org.apache.felix.dm.builder.lambda.Functions.CbRefServiceRefService;
@@ -30,11 +27,7 @@ import org.apache.felix.dm.builder.lambd
 import org.apache.felix.dm.builder.lambda.Functions.CbTypeComponentRefService;
 import org.apache.felix.dm.builder.lambda.Functions.CbTypeComponentRefServiceRefService;
 import org.apache.felix.dm.builder.lambda.Functions.CbTypeComponentService;
-import org.apache.felix.dm.builder.lambda.Functions.CbTypeComponentServiceDict;
-import org.apache.felix.dm.builder.lambda.Functions.CbTypeComponentServiceMap;
 import org.apache.felix.dm.builder.lambda.Functions.CbTypeComponentServiceService;
-import org.apache.felix.dm.builder.lambda.Functions.CbTypeDictServiceDictService;
-import org.apache.felix.dm.builder.lambda.Functions.CbTypeMapServiceMapService;
 import org.apache.felix.dm.builder.lambda.Functions.CbTypeRef;
 import org.apache.felix.dm.builder.lambda.Functions.CbTypeRefService;
 import org.apache.felix.dm.builder.lambda.Functions.CbTypeRefServiceRefService;
@@ -121,35 +114,37 @@ public abstract class ServiceCallbacksBu
         return (B) this;
     }
 	
-    public B cb(String add) {
-        return cb(add, null, null, null);
+    public B cb(String ... callbacks) {
+        return cbi(null, callbacks);
     }
     
-    public B cb(Object callbackInstance, String add) {
-        return cb(callbackInstance, add, null, null, null);
-    }
-
-    public B cb(String add, String remove) {
-        return cb(add, null, remove, null);
-    }
-
-    public B cb(Object callbackInstance, String add, String remove) {
-        return cb(callbackInstance, add, null, remove, null);
-    }
-
-    public B cb(String add, String change, String remove) {
-        return cb(add, change, remove, null);
-    }
-
-    public B cb(Object callbackInstance, String add, String change, String remove) {
-        return cb(callbackInstance, add, change, remove, null);
-    }
-
-    public B cb(String added, String changed, String removed, String swapped) {
-        return cb(null, added, changed, removed, swapped);
+    public B cbi(Object callbackInstance, String ... callbacks) {
+        Objects.nonNull(callbacks);
+        switch (callbacks.length) {
+        case 1:
+            cb(callbackInstance, callbacks[0], null, null, null);
+            break;
+            
+        case 2:
+            cb(callbackInstance, callbacks[0], null, callbacks[1], null);
+            break;
+            
+        case 3:
+            cb(callbackInstance, callbacks[0], callbacks[1], callbacks[2], null);
+            break;
+            
+        case 4:
+            cb(callbackInstance, callbacks[0], callbacks[1], callbacks[2], callbacks[3]);
+            break;
+            
+        default:
+            throw new IllegalArgumentException("wrong number of arguments: " + callbacks.length
+ ". " +
+                "Possible arguments: [add], [add, remove], [add, change, remove], or [add,
change, remove, swap]");
+        }
+        return (B) this;
     }
     
-    public B cb(Object callbackInstance, String added, String changed, String removed, String
swapped) {
+    private B cb(Object callbackInstance, String added, String changed, String removed, String
swapped) {
 		requiresNoMethodRefs();
         m_callbackInstance = callbackInstance;
 		m_added = added != null ? added : m_added;
@@ -274,18 +269,6 @@ public abstract class ServiceCallbacksBu
             swap.accept((T) inst, component, oref, oserv, nref, nserv));                
             
     }
     
-    public <T> B sw(CbTypeMapServiceMapService<T, S> swap) {
-        Class<T> type = Helpers.getLambdaGenericType(swap, 0);
-        return setComponentSwapCallbackRef(type, (inst, component, oref, oserv, nref, nserv)
->                          
-            swap.accept((T) inst, new SRefAsMap(oref), oserv, new SRefAsMap(nref), nserv));
               
-    }
-    
-    public <T> B sw(CbTypeDictServiceDictService<T, S> swap) {
-        Class<T> type = Helpers.getLambdaGenericType(swap, 0);
-        return setComponentSwapCallbackRef(type, (inst, component, oref, oserv, nref, nserv)
->
-             swap.accept((T) inst, new SRefAsDictionary(oref), oserv, new SRefAsDictionary(nref),
nserv));
-    }
-       
     public B swi(CbServiceService<S> swap) {
         return setInstanceSwapCallbackRef((inst, component, oref, oserv, nref, nserv) ->
swap.accept(oserv, nserv));
     }
@@ -302,26 +285,6 @@ public abstract class ServiceCallbacksBu
         return setInstanceSwapCallbackRef((inst, component, oref, oserv, nref, nserv) ->
swap.accept(component, oref, oserv, nref, nserv));
     }
     
-    public B swi(CbMapServiceMapService<S> swap) {
-        return setInstanceSwapCallbackRef((inst, component, oref, oserv, nref, nserv) ->

-            swap.accept(new SRefAsMap(oref), oserv, new SRefAsMap(nref), nserv));
-    }
-    
-    public B swi(CbComponentMapServiceMapService<S> swap) {
-        return setInstanceSwapCallbackRef((inst, component, oref, oserv, nref, nserv) ->

-            swap.accept(component, new SRefAsMap(oref), oserv, new SRefAsMap(nref), nserv));
-    }
-    
-    public B swi(CbDictServiceDictService<S> swap) {
-        return setInstanceSwapCallbackRef((inst, component, oref, oserv, nref, nserv) ->

-            swap.accept(new SRefAsDictionary(oref), oserv, new SRefAsDictionary(nref), nserv));
-    }
-    
-    public B swi(CbComponentDictServiceDictService<S> swap) {
-        return setInstanceSwapCallbackRef((inst, component, oref, oserv, nref, nserv) ->

-            swap.accept(component, new SRefAsDictionary(oref), oserv, new SRefAsDictionary(nref),
nserv));
-    }
-    
     protected <I> B setComponentCallbackRef(Cb cbType, Class<I> type, MethodRef<I,
S> ref) {
        cbType.ensureServiceCallback();
        requiresNoCallbacks();



Mime
View raw message