Skip to content

Instantly share code, notes, and snippets.

@chrisport
Last active Aug 29, 2015
Embed
What would you like to do?
public interface FieldsObservable {
// @param <E> the type of the Field and FieldObserver to guarantee compatibility
public <E> void addFieldObserver(Field<? extends E> field, FieldObserver<? super E> fieldObserver);
public <E> void removeFieldObserver(Field<? extends E> field, FieldObserver<? super E> fieldObserver);
public <E> void notifyFieldObservers(final Field<E> field, final E data);
}
public interface FieldObserver<E> {
/**
* To be called when data has changed.
* @param field the Field-tag of the data
* @param data the new data
*/
public void updateData(Field<E> field, E data);
}
//AbstractFieldsObservable to be replaced by component, will look similar to PropertyChangeListener
public interface Profile extends AbstractFieldsObservable {
public static final Field<String> FIRST_NAME = new Field("firstName");
private String firstName;
public void setFirstName(String firstName) {
this.firstName = firstName;
notifyFieldObservers(FIRST_NAME, firstName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment