Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Wellmann2021-08-23 21:38:13 +0000
committerThomas Watson2021-09-07 16:36:14 +0000
commit7e6f8c449ddaee2d942bfccfdc39ad1aaaaa4d28 (patch)
tree5d65f37e7c3c58fd1868e5c46521e4dd9f5a6b57
parent2b89ba1ad6faf11ea7b87e936d0a64217cc9b418 (diff)
downloadrt.equinox.framework-7e6f8c449ddaee2d942bfccfdc39ad1aaaaa4d28.tar.gz
rt.equinox.framework-7e6f8c449ddaee2d942bfccfdc39ad1aaaaa4d28.tar.xz
rt.equinox.framework-7e6f8c449ddaee2d942bfccfdc39ad1aaaaa4d28.zip
Bug 575579 - Unify InternalUtils.asList...() methods into one
Change-Id: I3d8f95a7d4e489590fece89c8ece453838bed36c Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net> Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/184338 Tested-by: Equinox Bot <equinox-bot@eclipse.org> Reviewed-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java2
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java8
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java8
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java22
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/InternalUtils.java106
5 files changed, 22 insertions, 124 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
index ff86c6c00..9320a7fde 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
@@ -1490,7 +1490,7 @@ public final class ModuleContainer implements DebugOptionsListener {
@Override
public Collection<BundleCapability> findProviders(Requirement requirement) {
- return InternalUtils.asListBundleCapability(moduleDatabase.findCapabilities(requirement));
+ return InternalUtils.asList(moduleDatabase.findCapabilities(requirement));
}
private Collection<Module> getModules(final Collection<Bundle> bundles) {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
index 0c3b523a9..b42a993a8 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
@@ -606,7 +606,7 @@ final class ModuleResolver {
if (DEBUG_PROVIDERS || DEBUG_HOOKS) {
filteredMatches = new ArrayList<>(candidates);
}
- hook.filterMatches((BundleRequirement) requirement, InternalUtils.asListBundleCapability(candidates));
+ hook.filterMatches((BundleRequirement) requirement, InternalUtils.asList(candidates));
if (DEBUG_PROVIDERS || DEBUG_HOOKS) {
filteredMatches.removeAll(candidates);
if (!filteredMatches.isEmpty()) {
@@ -643,7 +643,7 @@ final class ModuleResolver {
filterFailedToResolve(candidates);
Collections.sort(candidates, this);
- return InternalUtils.asListCapability(candidates);
+ return InternalUtils.asList(candidates);
}
private void filterFailedToResolve(List<ModuleCapability> candidates) {
@@ -865,7 +865,7 @@ final class ModuleResolver {
threadResolving.set(Boolean.TRUE);
try {
try {
- hook = adaptor.getResolverHookFactory().begin(InternalUtils.asListBundleRevision((List<? extends BundleRevision>) triggers));
+ hook = adaptor.getResolverHookFactory().begin(InternalUtils.asList((List<? extends BundleRevision>) triggers));
} catch (RuntimeException e) {
if (e.getCause() instanceof BundleException) {
BundleException be = (BundleException) e.getCause();
@@ -1322,7 +1322,7 @@ final class ModuleResolver {
private void filterResolvable() {
Collection<ModuleRevision> enabledCandidates = new ArrayList<>(unresolved);
- hook.filterResolvable(InternalUtils.asListBundleRevision((List<? extends BundleRevision>) enabledCandidates));
+ hook.filterResolvable(InternalUtils.asList((List<? extends BundleRevision>) enabledCandidates));
// do this the hard way because the 'optimization' in removeAll hurts us
for (ModuleRevision enabledRevision : enabledCandidates) {
disabled.remove(enabledRevision);
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java
index 86f927087..f057fa7ac 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java
@@ -98,12 +98,12 @@ public final class ModuleRevision implements BundleRevision {
@Override
public List<BundleCapability> getDeclaredCapabilities(String namespace) {
- return InternalUtils.asListBundleCapability(getModuleCapabilities(namespace));
+ return InternalUtils.asList(getModuleCapabilities(namespace));
}
@Override
public List<BundleRequirement> getDeclaredRequirements(String namespace) {
- return InternalUtils.asListBundleRequirement(getModuleRequirements(namespace));
+ return InternalUtils.asList(getModuleRequirements(namespace));
}
/**
@@ -138,12 +138,12 @@ public final class ModuleRevision implements BundleRevision {
@Override
public List<Capability> getCapabilities(String namespace) {
- return InternalUtils.asListCapability(getDeclaredCapabilities(namespace));
+ return InternalUtils.asList(getDeclaredCapabilities(namespace));
}
@Override
public List<Requirement> getRequirements(String namespace) {
- return InternalUtils.asListRequirement(getDeclaredRequirements(namespace));
+ return InternalUtils.asList(getDeclaredRequirements(namespace));
}
/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java
index 50bfc537e..4c46bab0b 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleWiring.java
@@ -14,12 +14,6 @@
package org.eclipse.osgi.container;
import static org.eclipse.osgi.internal.container.InternalUtils.asCopy;
-import static org.eclipse.osgi.internal.container.InternalUtils.asListBundleCapability;
-import static org.eclipse.osgi.internal.container.InternalUtils.asListBundleRequirement;
-import static org.eclipse.osgi.internal.container.InternalUtils.asListBundleWire;
-import static org.eclipse.osgi.internal.container.InternalUtils.asListCapability;
-import static org.eclipse.osgi.internal.container.InternalUtils.asListRequirement;
-import static org.eclipse.osgi.internal.container.InternalUtils.asListWire;
import java.net.URL;
import java.util.ArrayList;
@@ -162,13 +156,13 @@ public final class ModuleWiring implements BundleWiring {
@Override
public List<BundleCapability> getCapabilities(String namespace) {
- return asCopy(asListBundleCapability(getModuleCapabilities(namespace)));
+ return asCopy(getModuleCapabilities(namespace));
}
@Override
public List<BundleRequirement> getRequirements(String namespace) {
- return asCopy(asListBundleRequirement(getModuleRequirements(namespace)));
+ return asCopy(getModuleRequirements(namespace));
}
/**
@@ -221,12 +215,12 @@ public final class ModuleWiring implements BundleWiring {
@Override
public List<BundleWire> getProvidedWires(String namespace) {
- return asCopy(asListBundleWire(getWires(namespace, providedWires)));
+ return asCopy(getWires(namespace, providedWires));
}
@Override
public List<BundleWire> getRequiredWires(String namespace) {
- return asCopy(asListBundleWire(getWires(namespace, requiredWires)));
+ return asCopy(getWires(namespace, requiredWires));
}
private List<ModuleWire> getWires(String namespace, NamespaceList<ModuleWire> wires) {
@@ -308,22 +302,22 @@ public final class ModuleWiring implements BundleWiring {
@Override
public List<Capability> getResourceCapabilities(String namespace) {
- return asCopy(asListCapability(getModuleCapabilities(namespace)));
+ return asCopy(getModuleCapabilities(namespace));
}
@Override
public List<Requirement> getResourceRequirements(String namespace) {
- return asCopy(asListRequirement(getModuleRequirements(namespace)));
+ return asCopy(getModuleRequirements(namespace));
}
@Override
public List<Wire> getProvidedResourceWires(String namespace) {
- return asCopy(asListWire(getWires(namespace, providedWires)));
+ return asCopy(getWires(namespace, providedWires));
}
@Override
public List<Wire> getRequiredResourceWires(String namespace) {
- return asCopy(asListWire(getWires(namespace, requiredWires)));
+ return asCopy(getWires(namespace, requiredWires));
}
@Override
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/InternalUtils.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/InternalUtils.java
index e9daaac64..e8ced172e 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/InternalUtils.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/InternalUtils.java
@@ -30,118 +30,22 @@ import org.osgi.framework.namespace.BundleNamespace;
import org.osgi.framework.namespace.HostNamespace;
import org.osgi.framework.namespace.PackageNamespace;
import org.osgi.framework.wiring.BundleCapability;
-import org.osgi.framework.wiring.BundleRequirement;
-import org.osgi.framework.wiring.BundleRevision;
-import org.osgi.framework.wiring.BundleWire;
-import org.osgi.framework.wiring.BundleWiring;
-import org.osgi.resource.Capability;
-import org.osgi.resource.Requirement;
-import org.osgi.resource.Resource;
-import org.osgi.resource.Wire;
public class InternalUtils {
- public static <T> List<T> asCopy(List<T> list) {
+ public static <T> List<T> asCopy(List<? extends T> list) {
return new ArrayList<>(list);
}
/**
- * Coerce the generic type of a list from List<BundleCapability>
- * to List<Capability>
+ * Coerce the generic type of a list from List<? extends T> to List<T>
+ *
* @param l List to be coerced.
* @return l coerced to List<Capability>
*/
@SuppressWarnings("unchecked")
- public static List<Capability> asListCapability(List<? extends Capability> l) {
- return (List<Capability>) l;
- }
-
- /**
- * Coerce the generic type of a list from List<BundleRequirement>
- * to List<Requirement>
- * @param l List to be coerced.
- * @return l coerced to List<Requirement>
- */
- @SuppressWarnings("unchecked")
- public static List<Requirement> asListRequirement(List<? extends Requirement> l) {
- return (List<Requirement>) l;
- }
-
- /**
- * Coerce the generic type of a list from List<? extends BundleCapability>
- * to List<BundleCapability>
- * @param l List to be coerced.
- * @return l coerced to List<BundleCapability>
- */
- @SuppressWarnings("unchecked")
- public static List<BundleCapability> asListBundleCapability(List<? extends BundleCapability> l) {
- return (List<BundleCapability>) l;
- }
-
- /**
- * Coerce the generic type of a list from List<? extends BundleRequirement>
- * to List<BundleRequirement>
- * @param l List to be coerced.
- * @return l coerced to List<BundleRequirement>
- */
- @SuppressWarnings("unchecked")
- public static List<BundleRequirement> asListBundleRequirement(List<? extends BundleRequirement> l) {
- return (List<BundleRequirement>) l;
- }
-
- /**
- * Coerce the generic type of a list from List<? extends BundleWire>
- * to List<BundleWire>
- * @param l List to be coerced.
- * @return l coerced to List<BundleWire>
- */
- @SuppressWarnings("unchecked")
- public static List<BundleWire> asListBundleWire(List<? extends BundleWire> l) {
- return (List<BundleWire>) l;
- }
-
- /**
- * Coerce the generic type of a list from List<? extends BundleWire>
- * to List<BundleWire>
- * @param l List to be coerced.
- * @return l coerced to List<BundleWire>
- */
- @SuppressWarnings("unchecked")
- public static List<Wire> asListWire(List<? extends Wire> l) {
- return (List<Wire>) l;
- }
-
- /**
- * Coerce the generic type of a list from List<? extends BundleRevision>
- * to List<BundleRevision>
- * @param l List to be coerced.
- * @return l coerced to List<BundleRevision>
- */
- @SuppressWarnings("unchecked")
- public static List<BundleRevision> asListBundleRevision(List<? extends BundleRevision> l) {
- return (List<BundleRevision>) l;
- }
-
- /**
- * Coerce the generic type of a collection from Collection<? extends Resource>
- * to Collection<Resource>
- * @param c List to be coerced.
- * @return c coerced to Collection<Resource>
- */
- @SuppressWarnings("unchecked")
- public static Collection<Resource> asCollectionResource(Collection<? extends Resource> c) {
- return (Collection<Resource>) c;
- }
-
- /**
- * Coerce the generic type of a collection from Collection<? extends BundleWiring>
- * to Collection<BundleWiring>
- * @param c List to be coerced.
- * @return c coerced to Collection<BundleWiring>
- */
- @SuppressWarnings("unchecked")
- public static Collection<BundleWiring> asCollectionBundleWiring(Collection<? extends BundleWiring> c) {
- return (Collection<BundleWiring>) c;
+ public static <T> List<T> asList(List<? extends T> l) {
+ return (List<T>) l;
}
public static void filterCapabilityPermissions(Collection<? extends BundleCapability> capabilities) {

Back to the top