/** * Create a new aggregating {@link ChangeNotifier}. * * @param changeNotifiers the notifiers to aggregate */ AggregatingChangeNotifier(final Iterable<ChangeNotifier<T>> changeNotifiers) { this.changeNotifiers = ImmutableList.copyOf(changeNotifiers); // Set up forwarding of listeners for (final ChangeNotifier<T> changeNotifier : this.changeNotifiers) { changeNotifier.setListener(new Listener<T>() { @Override public void onChange(final ChangeNotification<T> ignored) { checkChange(); } }, false); } records = aggregateSet(); }
/** * Create a new aggregating {@link ChangeNotifier}. * * @param changeNotifiers the notifiers to aggregate */ AggregatingChangeNotifier(final Iterable<ChangeNotifier<T>> changeNotifiers) { this.changeNotifiers = ImmutableList.copyOf(changeNotifiers); // Set up forwarding of listeners for (final ChangeNotifier<T> changeNotifier : this.changeNotifiers) { changeNotifier.setListener(new Listener<T>() { @Override public void onChange(final ChangeNotification<T> ignored) { checkChange(); } }, false); } records = aggregateSet(); }
private synchronized void checkChange() { Set<T> currentRecords = aggregateSet(); if (ChangeNotifiers.isNoLongerInitial(currentRecords, records) || !currentRecords.equals(records)) { final ChangeNotification<T> changeNotification = newChangeNotification(currentRecords, records); records = currentRecords; fireRecordsUpdated(changeNotification); } }
private synchronized void checkChange() { Set<T> currentRecords = aggregateSet(); if (ChangeNotifiers.isNoLongerInitial(currentRecords, records) || !currentRecords.equals(records)) { final ChangeNotification<T> changeNotification = newChangeNotification(currentRecords, records); records = currentRecords; fireRecordsUpdated(changeNotification); } }