/** * Create a {@link RunnableChangeNotifier} that directly wraps a set of records given by a * {@link Supplier}. * * <p>Each call to {@link Runnable#run()} will cause the supplier to be polled and regular * change notifications to be triggered. * * <p>This implementation is useful for testing components that depend on a * {@link ChangeNotifier}. * * @param recordsSupplier The supplier of records * @param <T> The record type * @return A runnable notifier */ public static <T> RunnableChangeNotifier<T> direct(Supplier<Set<T>> recordsSupplier) { return new DirectChangeNotifier<T>(recordsSupplier); }
@Override public void run() { if (!run) { return; } final Set<T> current = recordsSupplier.get(); if (ChangeNotifiers.isNoLongerInitial(current, records) || !current.equals(records)) { final ChangeNotification<T> changeNotification = newChangeNotification(current, records); records = current; fireRecordsUpdated(changeNotification); } }
@Override public void run() { if (!run) { return; } final Set<T> current = recordsSupplier.get(); if (ChangeNotifiers.isNoLongerInitial(current, records) || !current.equals(records)) { final ChangeNotification<T> changeNotification = newChangeNotification(current, records); records = current; fireRecordsUpdated(changeNotification); } }
/** * Create a {@link RunnableChangeNotifier} that directly wraps a set of records given by a * {@link Supplier}. * * <p>Each call to {@link Runnable#run()} will cause the supplier to be polled and regular * change notifications to be triggered. * * <p>This implementation is useful for testing components that depend on a * {@link ChangeNotifier}. * * @param recordsSupplier The supplier of records * @param <T> The record type * @return A runnable notifier */ public static <T> RunnableChangeNotifier<T> direct(Supplier<Set<T>> recordsSupplier) { return new DirectChangeNotifier<T>(recordsSupplier); }
public static <T> RunnableChangeNotifier<T> direct(AtomicReference<Set<T>> recordsHolder) { return new DirectChangeNotifier<T>(supplierFromRef(recordsHolder)); }
public static <T> RunnableChangeNotifier<T> direct(AtomicReference<Set<T>> recordsHolder) { return new DirectChangeNotifier<T>(supplierFromRef(recordsHolder)); }