public class ChangeSupport
extends java.lang.Object
ChangeSupport
is responsible to notifies registered listeners upon changes made
to a StateObject
, those changes are either a property has changed (IPropertyChangeListener
)
or the content of a list has changed (IListChangeListener
).Constructor and Description |
---|
ChangeSupport(StateObject source)
Creates a new
ChangeSupport . |
Modifier and Type | Method and Description |
---|---|
<T> void |
addItem(ListHolderStateObject<T> source,
java.util.List<T> items,
java.lang.String listName,
T item)
Adds the given item as a child to the given list.
|
<T> void |
addItems(ListHolderStateObject<T> source,
java.util.List<T> list,
java.lang.String listName,
java.util.List<? extends T> items)
Adds the given items as children to the given list.
|
void |
addListChangeListener(java.lang.String listName,
IListChangeListener<?> listener)
Registers the given
IListChangeListener for the specified list. |
void |
addPropertyChangeListener(java.lang.String propertyName,
IPropertyChangeListener<?> listener)
Registers the given
IPropertyChangeListener for the specified property. |
<T> boolean |
canMoveDown(java.util.List<T> list,
T stateObject)
Determines whether the given item can be moved down by one position in the list owned by its
parent.
|
<T> boolean |
canMoveUp(java.util.List<T> list,
T item)
Determines whether the given item can be moved up by one position in the list owned by its
parent.
|
void |
firePropertyChanged(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Notifies the
IPropertyChangeListeners that have been registered
with the given property name that the property has changed. |
boolean |
hasListChangeListeners(java.lang.String listName)
Determines whether there are at least one
IListChangeListener registered to listen for
changes made to the list with the given list name. |
boolean |
hasPropertyChangeListeners(java.lang.String propertyName)
Determines whether there are at least one
IPropertyChangeListener registered to listen
for changes made to the property with the given property name. |
<T> void |
moveDown(ListHolderStateObject<T> source,
java.util.List<T> items,
java.lang.String listName,
T item)
Moves the given
StateObject down by one position in the list owned by its parent. |
<T> void |
moveUp(ListHolderStateObject<T> source,
java.util.List<T> items,
java.lang.String listName,
T item)
Moves the given item up by one position in the list owned by its parent.
|
<T> void |
removeItem(ListHolderStateObject<T> source,
java.util.List<T> items,
java.lang.String listName,
T item)
Removes the given item from the list of children.
|
<T> void |
removeItems(ListHolderStateObject<T> source,
java.util.List<? extends T> list,
java.lang.String listName,
java.util.Collection<? extends T> items)
Removes the given items from the list of children.
|
void |
removeListChangeListener(java.lang.String listName,
IListChangeListener<?> listener)
Unregisters the given
IListChangeListener that was registered for the specified list. |
void |
removePropertyChangeListener(java.lang.String propertyName,
IPropertyChangeListener<?> listener)
Unregisters the given
IPropertyChangeListener that was registered for the specified
property. |
<T> void |
replaceItem(ListHolderStateObject<T> source,
java.util.List<T> items,
java.lang.String listName,
int index,
T item)
Replaces the item at the given position by a new one.
|
<T> void |
replaceItems(ListHolderStateObject<T> source,
java.util.List<T> items,
java.lang.String listName,
java.util.List<T> newItems)
Replaces the given list by removing any existing items and adding the items contained in the
second list.
|
public ChangeSupport(StateObject source)
ChangeSupport
.source
- The object for which this object will take care of notifying the listeners upon
changes made to the object's internal statejava.lang.NullPointerException
- The source StateObject
cannot be null
public <T> void addItem(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, T item)
T
- The type of the itemssource
- The ListHolderStateObject
from where the change is comingitems
- The list of to which the child is addedlistName
- The name associated with the listitem
- The child to become a child of this onepublic <T> void addItems(ListHolderStateObject<T> source, java.util.List<T> list, java.lang.String listName, java.util.List<? extends T> items)
T
- The type of the itemssource
- The ListHolderStateObject
from where the change is cominglist
- The list of items to which the child is addedlistName
- The name associated with the listitems
- The child to become children of this onepublic void addListChangeListener(java.lang.String listName, IListChangeListener<?> listener)
IListChangeListener
for the specified list. The listener will be
notified only when items are added, removed, moved from the list.listName
- The name of the list for which the listener will be notified when the content
of the list has changedlistener
- The listener to be notified upon changesjava.lang.NullPointerException
- IListChangeListener
cannot be null
java.lang.IllegalArgumentException
- The listener is already registered with the list namepublic void addPropertyChangeListener(java.lang.String propertyName, IPropertyChangeListener<?> listener)
IPropertyChangeListener
for the specified property. The listener
will be notified only for changes to the specified property.propertyName
- The name of the property for which the listener was registeredlistener
- The listener to be notified upon changesjava.lang.NullPointerException
- IPropertyChangeListener
cannot be null
java.lang.IllegalArgumentException
- The listener is already registered with the property namepublic <T> boolean canMoveDown(java.util.List<T> list, T stateObject)
list
- The list used to determine if the given item can be moved down in that liststateObject
- The item that could potentially be moved downtrue
if the object can be moved down by one unit; false
otherwisepublic <T> boolean canMoveUp(java.util.List<T> list, T item)
list
- The list used to determine if the given item can be moved up in that listitem
- The item that could potentially be moved uptrue
if the object can be moved up by one unit; false
otherwisepublic void firePropertyChanged(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
IPropertyChangeListeners
that have been registered
with the given property name that the property has changed.propertyName
- The name of the property associated with the property changeoldValue
- The old value of the property that changednewValue
- The new value of the property that changedpublic boolean hasListChangeListeners(java.lang.String listName)
IListChangeListener
registered to listen for
changes made to the list with the given list name.listName
- The name of the list to check if it has registered listenerstrue
if listeners have been registered for the given list name;
false
otherwisepublic boolean hasPropertyChangeListeners(java.lang.String propertyName)
IPropertyChangeListener
registered to listen
for changes made to the property with the given property name.propertyName
- The name of the property to check if it has registered listenerstrue
if listeners have been registered for the given property name;
false
otherwisepublic <T> void moveDown(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, T item)
StateObject
down by one position in the list owned by its parent.T
- The type of the itemssource
- The ListHolderStateObject
from where the change is comingitems
- The list of items to which the child is moved downlistName
- The name associated with the listitem
- The child to move down within the listpublic <T> void moveUp(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, T item)
T
- The type of the itemssource
- The ListHolderStateObject
from where the change is comingitems
- The list of items to which the child is moved uplistName
- The name associated with the listitem
- The child to move up within the listpublic <T> void removeItem(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, T item)
T
- The type of the itemssource
- The ListHolderStateObject
from where the change is comingitems
- The list of item to which the child is removedlistName
- The name associated with the listitem
- The child to removed from the listpublic <T> void removeItems(ListHolderStateObject<T> source, java.util.List<? extends T> list, java.lang.String listName, java.util.Collection<? extends T> items)
T
- The type of the itemssource
- The ListHolderStateObject
from where the change is cominglist
- The list of items to which the child is removedlistName
- The name associated with the listitems
- The items to removed from the listpublic void removeListChangeListener(java.lang.String listName, IListChangeListener<?> listener)
IListChangeListener
that was registered for the specified list.
The listener will no longer be notified only when items are added, removed, moved from the
list.listName
- The name of the list for which the listener was registeredlistener
- The listener to unregisterjava.lang.NullPointerException
- IListChangeListener
cannot be null
java.lang.IllegalArgumentException
- The listener was never registered with the list namepublic void removePropertyChangeListener(java.lang.String propertyName, IPropertyChangeListener<?> listener)
IPropertyChangeListener
that was registered for the specified
property. The listener will no longer be notified when the property changes.propertyName
- The name of the property for which the listener was registeredlistener
- The listener to unregisterjava.lang.NullPointerException
- IPropertyChangeListener
cannot be null
java.lang.IllegalArgumentException
- The listener was never registered with the property namepublic <T> void replaceItem(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, int index, T item)
T
- The type of the itemssource
- The ListHolderStateObject
from where the change is comingitems
- The list of items to which a child is replacedlistName
- The name associated with the listindex
- The position of the item to replaceitem
- The item to replace the one at the given positionpublic <T> void replaceItems(ListHolderStateObject<T> source, java.util.List<T> items, java.lang.String listName, java.util.List<T> newItems)
T
- The type of the itemssource
- The ListHolderStateObject
from where the change is comingitems
- The list of items to which the child is removedlistName
- The name associated with the listnewItems
- The items to removed from the listEclipseLink 2.6.3, "build v20160428-59c81c5" API Reference