use of de.prob.animator.command.UnregisterFormulaCommand in project prob2 by bendisposto.
the class StateSpace method unsubscribe.
public boolean unsubscribe(final Object subscriber, final Collection<? extends IEvalElement> formulas, boolean unregister) {
boolean success = false;
final List<AbstractCommand> unsubscribeCmds = new ArrayList<>();
for (IEvalElement formula : formulas) {
if (formulaRegistry.containsKey(formula)) {
final WeakHashMap<Object, Object> subscribers = formulaRegistry.get(formula);
subscribers.remove(subscriber);
if (subscribers.isEmpty() && unregister) {
unsubscribeCmds.add(new UnregisterFormulaCommand(formula));
}
success = true;
}
}
if (!unsubscribeCmds.isEmpty()) {
execute(new ComposedCommand(unsubscribeCmds));
}
return success;
}
Aggregations