-
-
Save chrisport/748ba6d5370f769e58b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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