/** * Notifies listeners with error. * * @param name Name of the property * @param failureCause The cause of the error. */ protected final synchronized void notifyError(String name, Throwable failureCause) { if (isClosed()) { return; } for (ListenerCaller caller : listeners.get(name)) { caller.onError(name, failureCause); } }
@Override public final synchronized Cancellable addChangeListener(String name, PropertyChangeListener<T> listener) { ListenerCaller caller = new ListenerCaller(name, listener); listeners.put(name, caller); if (listenerAdded(name)) { T property = propertyCache.get(name); if (property != null) { caller.onChange(name, property); } } return caller; }
@Override public final synchronized Cancellable addChangeListener(String name, PropertyChangeListener<T> listener) { ListenerCaller caller = new ListenerCaller(name, listener); listeners.put(name, caller); if (listenerAdded(name)) { T property = propertyCache.get(name); if (property != null) { caller.onChange(name, property); } } return caller; }
/** * Notifies listeners with error. * * @param name Name of the property * @param failureCause The cause of the error. */ protected final synchronized void notifyError(String name, Throwable failureCause) { if (isClosed()) { return; } for (ListenerCaller caller : listeners.get(name)) { caller.onError(name, failureCause); } }
/** * Updates property value and notify listeners. * * @param name Name of the property * @param property New value of the property */ protected final synchronized void updateAndNotify(String name, T property) { if (isClosed()) { return; } if (property == null) { propertyCache.remove(name); } else { propertyCache.put(name, property); } for (ListenerCaller caller : listeners.get(name)) { caller.onChange(name, property); } }
/** * Updates property value and notify listeners. * * @param name Name of the property * @param property New value of the property */ protected final synchronized void updateAndNotify(String name, T property) { if (isClosed()) { return; } if (property == null) { propertyCache.remove(name); } else { propertyCache.put(name, property); } for (ListenerCaller caller : listeners.get(name)) { caller.onChange(name, property); } }