@Override public ListenableCollection<V> values() { return ListenableCollections.unmodifiableCollection(listenableMap.values()); } @Override
public MapResult(Threads threads, ListenableList<V> out, ListenableList<Pair<U,Throwable>> errorsOut) { this.values = ListenableCollections.unmodifiableList(out); this.threads = threads; this.errors = ListenableCollections.unmodifiableList(errorsOut); }
/** * Wraps a collection in a listenable collection.<br> * The type of the listenable collection returned will depend on that of the provided collection : * <ul> * <li>wrapping a Set<T> will return a ListenableSet<T>, using ListenableCollections.listenableSet(Set<T>)</li> * <li>wrapping a List<T> will return a ListenableList<T>, using ListenableCollections.listenableList(List<T>)</li> * <li>wrapping a ListenableCollection<T> will return the same object</li> * <li>otherwise a instance of a ListenableCollection<T> will be returned.</li> * </ul> * @param <T> component type * @param collectionToWrap * @return listenable collection that uses the provided collection as storage */ public static final <T> ListenableCollection<T> listenableCollection(Collection<T> collectionToWrap) { if (collectionToWrap instanceof ListenableCollection<?>) return (ListenableCollection<T>)collectionToWrap; if (collectionToWrap instanceof Set<?>) { return listenableSet((Set<T>)collectionToWrap); } else if (collectionToWrap instanceof List<?>) { return listenableList((List<T>)collectionToWrap); } return new DefaultListenableCollection<T>(collectionToWrap); }
final ListenableList<V> out = ListenableCollections.synchronizedList(ListenableCollections.listenableList(new ArrayList<V>(input.size()))); final ListenableList<Pair<U,Throwable>> errorsOut = ListenableCollections.synchronizedList(ListenableCollections.listenableList(new ArrayList<Pair<U,Throwable>>()));
@Override public ListenableSet<Entry<K, V>> entrySet() { return ListenableCollections.unmodifiableSet(listenableMap.entrySet()); } @Override
/** * Create a listenable list that will dynamically reflect the contents of the source listenable collection.<br> * This is useful for instance when you want to put the contents of a set in a swing JList (then use new JList(new ListenableListModel(ListenableCollections.asList(yourSet)))). * @param <T> type of the elements of the collection * @param source collection that is to be adapted to a listenable list * @return source if it is already a listenable list, otherwise a new listenable list that is two-ways bound to the source collection. */ public static <T> ListenableList<T> asList(ListenableCollection<T> source) { if (source instanceof ListenableList<?>) return (ListenableList<T>)source; ListenableList<T> out = new DefaultListenableList<T>(new ArrayList<T>(source)); bind(source, out); return out; }
public ListenableCollection<V> values() { if (values == null) { valuesSupport = new ListenableSupport<V>(); values = ListenableCollections.unmodifiableCollection(new DefaultListenableCollection<V>(map.values(), valuesSupport)); } return values; }