package model; /** * Data observers for GUI data binding. */ @FunctionalInterface public interface Observer { /** * The data is just added to a list. Index will be its index. */ int DIRECTION_ADD = 0; /** * The data is just removed from a list. Index will be its previous index. */ int DIRECTION_REMOVE = 1; /** * The data is modified, either or not in a list. Index will be either INDEX_NOT_IN_LIST or its index. */ int DIRECTION_CHANGE = 2; /** * A special index representing that the data is not in a list. */ int INDEX_NOT_IN_LIST = -1; /** * EFFECTS: Handle data change. * REQUIRES: data != null, direction be DIRECTION_*, index >= 0 or == INDEX_NOT_IN_LIST. */ void accept(T data, int direction, int index); }