Package com.sun.javafx.collections
Class ObservableSetWrapper<E>
java.lang.Object
com.sun.javafx.collections.ObservableSetWrapper<E>
- All Implemented Interfaces:
 Iterable<E>,Collection<E>,Set<E>,Observable,ObservableSet<E>
A Set wrapper class that implements observability.
- 
Constructor Summary
ConstructorsConstructorDescriptionObservableSetWrapper(Set<E> set) Creates new instance of ObservableSet that wraps the particular set specified by the parameter set. - 
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the specific element into this set and call all the registered observers unless the set already contains the element.booleanaddAll(Collection<? extends E> c) Adds the elements from the specified collection.voidaddListener(InvalidationListener listener) Adds anInvalidationListenerwhich will be notified whenever theObservablebecomes invalid.voidaddListener(SetChangeListener<? super E> observer) Add a listener to this observable set.voidclear()Removes all the elements from this set.booleanReturns true if this set contains specified element.booleancontainsAll(Collection<?> c) Test this set if it contains all the elements in the specified collection.booleanIndicates whether some other object is "equal to" the wrapped set.inthashCode()Returns the hash code for the wrapped set.booleanisEmpty()Returns true if this set contains no elements.iterator()Returns an iterator over the elements in this set.booleanRemoves the specific element from this set and call all the registered observers if the set contained the element.booleanremoveAll(Collection<?> c) Removes all the elements that are contained in the specified collection.voidremoveListener(InvalidationListener listener) Removes the given listener from the list of listeners, that are notified whenever the value of theObservablebecomes invalid.voidremoveListener(SetChangeListener<? super E> observer) Tries to removed a listener from this observable set.booleanretainAll(Collection<?> c) Keeps only elements that are included the specified collection.intsize()Returns number of elements contained in this set.Object[]toArray()Returns an array containing all of the elements in this set.<T> T[]toArray(T[] a) Returns an array containing all of the elements in this set.toString()Returns the String representation of the wrapped set.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, streamMethods inherited from interface java.util.Set
spliterator 
- 
Constructor Details
- 
ObservableSetWrapper
Creates new instance of ObservableSet that wraps the particular set specified by the parameter set.- Parameters:
 set- the set being wrapped
 
 - 
 - 
Method Details
- 
addListener
Adds anInvalidationListenerwhich will be notified whenever theObservablebecomes invalid. If the same listener is added more than once, then it will be notified more than once. That is, no check is made to ensure uniqueness.Note that the same actual
InvalidationListenerinstance may be safely registered for differentObservables.The
Observablestores a strong reference to the listener which will prevent the listener from being garbage collected and may result in a memory leak. It is recommended to either unregister a listener by callingremoveListenerafter use or to use an instance ofWeakInvalidationListeneravoid this situation.- Specified by:
 addListenerin interfaceObservable- Parameters:
 listener- The listener to register- See Also:
 
 - 
removeListener
Removes the given listener from the list of listeners, that are notified whenever the value of theObservablebecomes invalid.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.
- Specified by:
 removeListenerin interfaceObservable- Parameters:
 listener- The listener to remove- See Also:
 
 - 
addListener
Add a listener to this observable set.- Specified by:
 addListenerin interfaceObservableSet<E>- Parameters:
 observer- the listener for listening to the set changes
 - 
removeListener
Tries to removed a listener from this observable set. If the listener is not attached to this list, nothing happens.- Specified by:
 removeListenerin interfaceObservableSet<E>- Parameters:
 observer- a listener to remove
 - 
size
public int size()Returns number of elements contained in this set. - 
isEmpty
public boolean isEmpty()Returns true if this set contains no elements. - 
contains
Returns true if this set contains specified element. - 
iterator
Returns an iterator over the elements in this set. If the iterator'sremove()method is called then the registered observers are called as well. - 
toArray
Returns an array containing all of the elements in this set. - 
toArray
public <T> T[] toArray(T[] a) Returns an array containing all of the elements in this set. The runtime type of the returned array is that of the specified array.- Specified by:
 toArrayin interfaceCollection<E>- Specified by:
 toArrayin interfaceSet<E>- Parameters:
 a- the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated- Returns:
 - an array containing all of the elements in this set
 - See Also:
 
 - 
add
Adds the specific element into this set and call all the registered observers unless the set already contains the element. Returns true in the case the element was added to the set. - 
remove
Removes the specific element from this set and call all the registered observers if the set contained the element. Returns true in the case the element was removed from the set. - 
containsAll
Test this set if it contains all the elements in the specified collection. In such case returns true.- Specified by:
 containsAllin interfaceCollection<E>- Specified by:
 containsAllin interfaceSet<E>- Parameters:
 c- collection to be checked for containment in this set- Returns:
 - true if the set contains all the elements in the specified collection
 - See Also:
 
 - 
addAll
Adds the elements from the specified collection. Observers are called for each elements that was not already present in the set. - 
retainAll
Keeps only elements that are included the specified collection. All other elements are removed. For each removed element all the observers are called. - 
removeAll
Removes all the elements that are contained in the specified collection. Observers are called for each removed element. - 
clear
public void clear()Removes all the elements from this set. Observers are called for each element. - 
toString
Returns the String representation of the wrapped set. - 
equals
Indicates whether some other object is "equal to" the wrapped set. - 
hashCode
public int hashCode()Returns the hash code for the wrapped set. 
 -