Commit 1a18dbcf authored by Nico Mack's avatar Nico Mack

added silently parameters to clear and setValue methods

parent 4d7ee192
......@@ -16,8 +16,12 @@ import java.util.Map.Entry;
// ***************************************************************************
public class ApplicationContext {
private static Map<String, Variable<?>> context = new HashMap<>();
public static final boolean SILENTLY = true;
public static final boolean NOTIFYING = false;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s)
......@@ -66,14 +70,20 @@ public class ApplicationContext {
// ---------------------------------------------------------------------------
public static boolean updateVariable(String identifier, Object value) {
public static boolean updateVariable(String identifier, Object value, boolean silently) {
boolean assigned = false;
if (context.containsKey(identifier)) {
Variable<?> variable = context.get(identifier);
if (variable != null) {
variable.setValueFromObject(value);
assigned = true;
synchronized (variable) {
if (silently)
variable.suspendListenerNotification(true);
variable.setValueFromObject(value);
if (silently)
variable.suspendListenerNotification(false);
assigned = true;
}
}
}
return assigned;
......@@ -81,14 +91,20 @@ public class ApplicationContext {
// ---------------------------------------------------------------------------
public static boolean clearVariable(String identifier) {
public static boolean clearVariable(String identifier, boolean silently) {
boolean cleared = false;
if (context.containsKey(identifier)) {
Variable<?> variable = context.get(identifier);
if (variable != null) {
variable.clear();
cleared = true;
synchronized (variable) {
if (silently)
variable.suspendListenerNotification(true);
variable.clear();
if (silently)
variable.suspendListenerNotification(false);
cleared = true;
}
}
}
return cleared;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment