From 306daa015ce7a333db41287b24525b4485b88bc7 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Tue, 15 May 2018 10:47:31 +0200 Subject: Use lambdas in org.eclipse.e4.core.di Change-Id: Ieb055388f3b13a6b7e22d4e52ace924d9bcdbaf0 Signed-off-by: Lars Vogel --- .../eclipse/e4/core/internal/di/InjectorImpl.java | 23 ++++++++-------------- .../e4/core/internal/di/osgi/ProviderHelper.java | 11 +++-------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java index 9492e2e1c..c47f75c73 100644 --- a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java +++ b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java @@ -25,7 +25,6 @@ import java.security.CodeSource; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -382,13 +381,10 @@ public class InjectorImpl implements IInjector { ArrayList> sortedConstructors = new ArrayList<>(constructors.length); for (Constructor constructor : constructors) sortedConstructors.add(constructor); - Collections.sort(sortedConstructors, new Comparator>() { - @Override - public int compare(Constructor c1, Constructor c2) { - int l1 = c1.getParameterTypes().length; - int l2 = c2.getParameterTypes().length; - return l2 - l1; - } + Collections.sort(sortedConstructors, (c1, c2) -> { + int l1 = c1.getParameterTypes().length; + int l2 = c2.getParameterTypes().length; + return l2 - l1; }); for (Constructor constructor : sortedConstructors) { @@ -822,13 +818,10 @@ public class InjectorImpl implements IInjector { constructors = c.getDeclaredConstructors(); // Sort the constructors by descending number of constructor // arguments - Arrays.sort(constructors, new Comparator>() { - @Override - public int compare(Constructor c1, Constructor c2) { - int l1 = c1.getParameterTypes().length; - int l2 = c2.getParameterTypes().length; - return l2 - l1; - } + Arrays.sort(constructors, (c1, c2) -> { + int l1 = c1.getParameterTypes().length; + int l2 = c2.getParameterTypes().length; + return l2 - l1; }); constructorsCache.put(c, constructors); } diff --git a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/osgi/ProviderHelper.java b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/osgi/ProviderHelper.java index e318be4ac..82e63053d 100644 --- a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/osgi/ProviderHelper.java +++ b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/osgi/ProviderHelper.java @@ -24,8 +24,6 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceEvent; -import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceReference; /** @@ -43,12 +41,9 @@ public class ProviderHelper { BundleContext bundleContext = bundle.getBundleContext(); String filter = '(' + Constants.OBJECTCLASS + '=' + ExtendedObjectSupplier.SERVICE_NAME + ')'; try { - bundleContext.addServiceListener(new ServiceListener() { - @Override - public void serviceChanged(ServiceEvent event) { - synchronized (extendedSuppliers) { - extendedSuppliers.clear(); - } + bundleContext.addServiceListener(event -> { + synchronized (extendedSuppliers) { + extendedSuppliers.clear(); } }, filter); } catch (InvalidSyntaxException e) { -- cgit v1.2.3