use of com.revolsys.beans.NonWeakListener in project com.revolsys.open by revolsys.
the class Property method getPropertyChangeListener.
@SuppressWarnings("unchecked")
static PropertyChangeListener getPropertyChangeListener(final Object listener) {
if (listener instanceof PropertyChangeListener) {
final PropertyChangeListener propertyChangeListener = (PropertyChangeListener) listener;
if (propertyChangeListener instanceof NonWeakListener) {
return propertyChangeListener;
} else {
final WeakPropertyChangeListener weakListener = new WeakPropertyChangeListener(propertyChangeListener);
return weakListener;
}
} else if (listener instanceof Consumer) {
final Consumer<Object> consumer = (Consumer<Object>) listener;
return (e) -> {
final Object object = e.getNewValue();
consumer.accept(object);
};
} else {
return null;
}
}
Aggregations