javafx.collections.ObservableSet implementation that allows one to subscribe to updates within
the elements themselves. For example, if one stored javafx.scene.text.Text in this set and one wanted
to be notified each time one of the text's textProperty() changed,
one could use addSubscriber(Function) with the function
text -> {
EventStream<String> textValues = EventStreams.nonNullValuesOf(text.textProperty());
return EventStreams.combine(textValues, otherTextValuesFromSomewhereElse)
.subscribe(tuple2 -> {
String quantity = tuple2.get1();
String unit = tuple2.get2();
someOtherObjectOnTheScreen.setText("Will send " + quantity + " " + unit + " to the department");
});
}
When the element is removed from the set, the function's returned Subscription is
unsubscribed to prevent any memory leaks.
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private final List | |
| private final Map | |
| private final List |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | add(E e)
Overrides java. Implements java. Adds the specified element to this set if it is not already present (optional operation). |
| public Subscription | addChangeListener(SetChangeListener<? super E> listener)
Helper method for adding a change listener that can be removed by calling
|
| public Subscription | addInvalidationListener(InvalidationListener listener)
Helper method for adding an invalidation listener that can be removed by calling
|
| public void | addListener(SetChangeListener<? super E> listener)
Implements javafx. Add a listener to this observable set. |
| public void | addListener(InvalidationListener listener)
Implements javafx. Adds an |
| public Subscription | addSubscriber(Function<? super E, Subscription> subscriber)
Subscribes to all current and future elements' internal changes in this set until either they are removed
or this subscriber is removed by calling |
| private void | |
| private void | |
| private void | |
| public Iterator | iterator()
Implements abstract java. Implements java. Returns an iterator over the elements in this set. |
| public boolean | remove(Object o)
Overrides java. Implements java. Removes the specified element from this set if it is present (optional operation). |
| public void | removeListener(SetChangeListener<? super E> listener)
Implements javafx. Tries to removed a listener from this observable set. |
| public void | removeListener(InvalidationListener listener)
Implements javafx. Removes the given listener from the list of listeners, that are notified
whenever the value of the |
| private void | |
| public int | size()
Implements abstract java. Implements java. Returns the number of elements in this set (its cardinality). |
| changeListeners | back to summary |
|---|---|
| private final List<SetChangeListener<? super E>> changeListeners | |
| invalidationListeners | back to summary |
|---|---|
| private final List<InvalidationListener> invalidationListeners | |
| map | back to summary |
|---|---|
| private final Map<E, List<Subscription>> map | |
| subscribers | back to summary |
|---|---|
| private final List<Function<? super E, Subscription>> subscribers | |
| SubscribeableContentsObsSet | back to summary |
|---|---|
| public SubscribeableContentsObsSet() | |
| SubscribeableContentsObsSet | back to summary |
|---|---|
| public SubscribeableContentsObsSet(Comparator<? super E> comparator) | |
| add | back to summary |
|---|---|
| public boolean add(E e) Overrides java. Implements java. Doc from java. Adds the specified element to this set if it is not already present
(optional operation). More formally, adds the specified element
The stipulation above does not imply that sets must accept all
elements; sets may refuse to add any particular element, including
| |
| addChangeListener | back to summary |
|---|---|
| public Subscription addChangeListener(SetChangeListener<? super E> listener) Helper method for adding a change listener that can be removed by calling
| |
| addInvalidationListener | back to summary |
|---|---|
| public Subscription addInvalidationListener(InvalidationListener listener) Helper method for adding an invalidation listener that can be removed by calling
| |
| addListener | back to summary |
|---|---|
| public void addListener(SetChangeListener<? super E> listener) Implements javafx. Doc from javafx. Add a listener to this observable set.
| |
| addListener | back to summary |
|---|---|
| public void addListener(InvalidationListener listener) Implements javafx. Doc from javafx. Adds an
Note that the same actual
The
| |
| addSubscriber | back to summary |
|---|---|
| public Subscription addSubscriber(Function<? super E, Subscription> subscriber) Subscribes to all current and future elements' internal changes in this set until either they are removed
or this subscriber is removed by calling | |
| fireElementAdded | back to summary |
|---|---|
| private void fireElementAdded(E elem) | |
| fireElementRemoved | back to summary |
|---|---|
| private void fireElementRemoved(E elem) | |
| invalidateSet | back to summary |
|---|---|
| private void invalidateSet() | |
| iterator | back to summary |
|---|---|
| public Iterator Implements abstract java. Implements java. Doc from java. Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).
| |
| remove | back to summary |
|---|---|
| public boolean remove(Object o) Overrides java. Implements java. Doc from java. Removes the specified element from this set if it is present
(optional operation). More formally, removes an element
| |
| removeListener | back to summary |
|---|---|
| public void removeListener(SetChangeListener<? super E> listener) Implements javafx. Doc from javafx. Tries to removed a listener from this observable set. If the listener is not attached to this list, nothing happens.
| |
| removeListener | back to summary |
|---|---|
| public void removeListener(InvalidationListener listener) Implements javafx. Doc from javafx. Removes the given listener from the list of listeners, that are notified
whenever the value of the If the given listener has not been previously registered (i.e. it was never added) then this method call is a no-op. If it had been previously added then it will be removed. If it had been added more than once, then only the first occurrence will be removed.
| |
| removeSubscriber | back to summary |
|---|---|
| private void removeSubscriber(Function<? super E, Subscription> subscriber) | |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this set (its cardinality). If this
set contains more than
| |