Bug 575015 - [Clean-up] Use Compator.comparing
Changes found by SonarLint and applied manually.
Change-Id: I2191c0cbefdb52a08cfbf239dafd3f5cba29420b
Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/183389
Tested-by: Equinox Bot <equinox-bot@eclipse.org>
Reviewed-by: Lars Vogel <Lars.Vogel@vogella.com>
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
index 8bd3e5b..0308761 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java
@@ -3820,19 +3820,8 @@
public void testSelectionPolicy() throws BundleException {
State state = buildEmptyState();
Resolver resolver = state.getResolver();
- resolver.setSelectionPolicy(new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
- if (!(o1 instanceof BaseDescription) || !(o2 instanceof BaseDescription))
- throw new IllegalArgumentException();
- Version v1 = null;
- Version v2 = null;
- v1 = ((BaseDescription) o1).getVersion();
- v2 = ((BaseDescription) o2).getVersion();
- // only take version in to account and use lower versions over higher ones
- return v1.compareTo(v2);
- }
- });
+ // only take version into account and use lower versions over higher ones
+ resolver.setSelectionPolicy(Comparator.comparing(BaseDescription::getVersion));
Hashtable manifest = new Hashtable();
long bundleID = 0;
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); //$NON-NLS-1$