sk.seges.sesam.domain.ValueHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sesam-core Show documentation
Show all versions of sesam-core Show documentation
Core interfaces and support classes to ease
information systems development. Usually requirement is to implement
multi-tier application using database, DAOs, services, models and
listeners.
The newest version!
/**
*
*/
package sk.seges.sesam.domain;
import java.util.ArrayList;
import java.util.List;
import sk.seges.sesam.handler.ValueChangeHandler;
/**
* Object used to hold a value. Value placed in value holder can change over
* time and observer of value holder can be notified of this change.
*
* @param
* Type of value held.
* @author eldzi
* @since 15.12.2007
*/
public class ValueHolder implements IObservableObject {
public static final String PROPERTY_VALUE="value";
private T value;
protected List> handlers = new ArrayList>();
public ValueHolder() {}
public ValueHolder(T value) {
this.value = value;
}
public T getValue() {
return value;
}
public void setValue(T value) {
T oldValue = this.value;
this.value = value;
for (ValueChangeHandler handler: handlers) {
handler.onValueChanged(oldValue, value);
}
}
/* (non-Javadoc)
* @see sk.seges.sesam.domain.IObservableObject#addPropertyChangeListener(java.beans.PropertyChangeListener)
*/
public void addPropertyChangeListener(ValueChangeHandler listener) {
handlers.add(listener);
}
/* (non-Javadoc)
* @see sk.seges.sesam.domain.IObservableObject#removePropertyChangeListener(java.beans.PropertyChangeListener)
*/
@Override
public void removePropertyChangeListener(ValueChangeHandler listener) {
handlers.remove(listener);
}
}