Errai 3.0.1-SNAPSHOT

org.jboss.errai.databinding.client
Class PropertyChangeHandlerSupport

java.lang.Object
  extended by org.jboss.errai.databinding.client.PropertyChangeHandlerSupport

public class PropertyChangeHandlerSupport
extends Object

This is a utility class that can be used by implementations of HasPropertyChangeHandlers. It manages a list of handlers and dispatches PropertyChangeEvents.

Author:
David Cracauer , Christian Sadilek

Constructor Summary
PropertyChangeHandlerSupport()
           
 
Method Summary
 void addPropertyChangeHandler(PropertyChangeHandler<?> handler)
          Adds a PropertyChangeHandler that will be notified when any property of the bound object changes.
 void addPropertyChangeHandler(String name, PropertyChangeHandler<?> handler)
          Adds a PropertyChangeHandler that will be notified only when the given property of the bound object changes.
 void notifyHandlers(PropertyChangeEvent<?> event)
          Notify registered PropertyChangeHandlers of a PropertyChangeEvent.
 void removePropertyChangeHandler(PropertyChangeHandler<?> handler)
          Removes a PropertyChangeHandler from the list of handlers.
 void removePropertyChangeHandler(String name, PropertyChangeHandler<?> handler)
          Removes a PropertyChangeHandler, causing it no longer to be notified only when the given property of the bound object changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyChangeHandlerSupport

public PropertyChangeHandlerSupport()
Method Detail

addPropertyChangeHandler

public void addPropertyChangeHandler(PropertyChangeHandler<?> handler)
Adds a PropertyChangeHandler that will be notified when any property of the bound object changes. Multiple handlers can be registered. If the same handler instance is passed multiple times, it will be notified multiple times.

Parameters:
handler - The PropertyChangeHandler to add, must not be null.

addPropertyChangeHandler

public void addPropertyChangeHandler(String name,
                                     PropertyChangeHandler<?> handler)
Adds a PropertyChangeHandler that will be notified only when the given property of the bound object changes. Multiple handlers can be registered for each property. If the same handler instance is passed for the same property multiple times, it will be notified multiple times. If the property name does not correspond to a property of the bound object, no exception is thrown, but no events will ever be delivered to the handler.

Parameters:
name - The property name for which notifications should be sent.
handler - The PropertyChangeHandler to add, must not be null.

removePropertyChangeHandler

public void removePropertyChangeHandler(PropertyChangeHandler<?> handler)
Removes a PropertyChangeHandler from the list of handlers. If the handler was added more than once to the same event source, it will be notified one less time after being removed. If handler is null, or was never added, no exception is thrown and no action is taken.

Parameters:
handler - The PropertyChangeHandler to remove.

removePropertyChangeHandler

public void removePropertyChangeHandler(String name,
                                        PropertyChangeHandler<?> handler)
Removes a PropertyChangeHandler, causing it no longer to be notified only when the given property of the bound object changes. If the same handler instance was added for the same property multiple times, it will be notified one less time per change than before. If handler is null, was never added, or the property name does not correspond to a property of the bound object, no exception is thrown and no action is taken.

Parameters:
name - The property name for which notifications should be sent.
handler - The PropertyChangeHandler to add, must not be null.

notifyHandlers

public void notifyHandlers(PropertyChangeEvent<?> event)
Notify registered PropertyChangeHandlers of a PropertyChangeEvent. Will only dispatch events that represent a change. If oldValue and newValue are equal, the event will be ignored.

Parameters:
event - PropertyChangeEvent to provide to handlers.

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.