Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2009-12-29 14:05:46 +0000
committerThomas Hallgren2009-12-29 14:05:46 +0000
commit80a149765cd58222e1d418a22cf4ddc24db74ef7 (patch)
treef76b8dcb202eb5b66a90d6c660708cf04f35f469
parent7351e428f467348a3b8f7ce2b0ba7248a35794b0 (diff)
downloadrt.equinox.p2-80a149765cd58222e1d418a22cf4ddc24db74ef7.tar.gz
rt.equinox.p2-80a149765cd58222e1d418a22cf4ddc24db74ef7.tar.xz
rt.equinox.p2-80a149765cd58222e1d418a22cf4ddc24db74ef7.zip
Removed usage of Class.cast since it was introduced in Java 1.5
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherInfo.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java7
2 files changed, 8 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherInfo.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherInfo.java
index 0e4c6b779..10a8c6689 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherInfo.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherInfo.java
@@ -33,12 +33,14 @@ public class PublisherInfo implements IPublisherInfo {
return adviceList;
}
+ @SuppressWarnings("unchecked")
public <T extends IPublisherAdvice> Collection<T> getAdvice(String configSpec, boolean includeDefault, String id, Version version, Class<T> type) {
ArrayList<T> result = new ArrayList<T>();
for (Iterator<IPublisherAdvice> i = adviceList.iterator(); i.hasNext();) {
IPublisherAdvice advice = i.next();
if (type.isInstance(advice) && advice.isApplicable(configSpec, includeDefault, id, version))
- result.add(type.cast(advice));
+ // Ideally, we would use Class.cast here but it was introduced in Java 1.5
+ result.add((T) advice);
}
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
index 22c7a5ff9..d8417a094 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUI.java
@@ -108,13 +108,16 @@ public class ProvUI {
return queryContext;
}
+ @SuppressWarnings("unchecked")
public static <T> T getAdapter(Object object, Class<T> adapterType) {
if (object == null)
return null;
if (adapterType.isInstance(object))
- return adapterType.cast(object);
+ // Ideally, we would use Class.cast here but it was introduced in Java 1.5
+ return (T) object;
if (object instanceof IAdaptable)
- return adapterType.cast(((IAdaptable) object).getAdapter(adapterType));
+ // Ideally, we would use Class.cast here but it was introduced in Java 1.5
+ return (T) ((IAdaptable) object).getAdapter(adapterType);
return null;
}

Back to the top