From 7ea69a46972b1c5ed621936cccb8435a2b5a2163 Mon Sep 17 00:00:00 2001 From: codistmonk Date: Mon, 3 Sep 2012 10:54:45 +0000 Subject: [PATCH] [Aprog] Updated Context (added setter that takes the variable type as additional argument). git-svn-id: https://aprog.svn.sourceforge.net/svnroot/aprog/trunk@190 7cbf5e2b-b55d-4b93-acdd-c0d7b961df51 --- .../src/net/sourceforge/aprog/context/Context.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Aprog/src/net/sourceforge/aprog/context/Context.java b/Aprog/src/net/sourceforge/aprog/context/Context.java index d74a163..28159cd 100644 --- a/Aprog/src/net/sourceforge/aprog/context/Context.java +++ b/Aprog/src/net/sourceforge/aprog/context/Context.java @@ -72,12 +72,11 @@ public final class Context extends AbstractObservable implemen * @return The old value *
Maybe null */ - @SuppressWarnings("unchecked") - public final T set(final String variableName, final T value) { + public final T set(final String variableName, final T value, final Class variableType) { final Variable variable = this.getVariable(variableName); if (variable == null) { - this.putVariable(new AtomicVariable((Class) (value == null ? Object.class : value.getClass()), variableName, value)); + this.putVariable(new AtomicVariable(variableType, variableName, value)); return null; } @@ -93,6 +92,22 @@ public final class Context extends AbstractObservable implemen * * @param The type of the variable value * @param variableName + *
Not null + * @param value + *
Maybe null + *
Shared + * @return The old value + *
Maybe null + */ + @SuppressWarnings("unchecked") + public final T set(final String variableName, final T value) { + return this.set(variableName, value, (Class) (value == null ? Object.class : value.getClass())); + } + + /** + * + * @param The type of the variable value + * @param variableName *
Maybe null * @return The removed variable *
Maybe null -- 2.11.4.GIT