Bug 313939 - IEclipseContext#set(Class,Object) should be really typesafe
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/IEclipseContext.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/IEclipseContext.java index c47f3d6..664a227 100644 --- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/IEclipseContext.java +++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/IEclipseContext.java
@@ -173,10 +173,10 @@ /** * Sets a value to be associated with a given class in this context. * @param clazz The class to store a value for - * @param value The value to be stored, or a {@link ContextFunction} that can return the stored value. + * @param value The value to be stored * @see #set(String, Object) */ - public void set(Class<?> clazz, Object value); + public <T> void set(Class<T> clazz, T value); /** * Modifies the value to be associated with the given name. @@ -199,11 +199,11 @@ /** * Modifies the value to be associated with the given class. * @param clazz The class to store a value for - * @param value The value to be stored, or a {@link ContextFunction} that can return the stored value. + * @param value The value to be stored * @throws IllegalArgumentException if the variable has not been declared as modifiable * @see #modify(String, Object) */ - public void modify(Class<?> clazz, Object value); + public <T> void modify(Class<T> clazz, T value); /** * Declares the named value as modifiable by descendants of this context. If the value does not
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java index 01f563c..8147402 100644 --- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java +++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java
@@ -653,7 +653,7 @@ return containsKey(clazz.getName()); } - public void set(Class<?> clazz, Object value) { + public <T> void set(Class<T> clazz, T value) { set(clazz.getName(), value); } @@ -665,7 +665,7 @@ return clazz.cast(getLocal(clazz.getName())); } - public void modify(Class<?> clazz, Object value) { + public <T> void modify(Class<T> clazz, T value) { modify(clazz.getName(), value); }