55 * denotes the sublist of the list that contain new elements. Note that this is a half-open
56 * interval, so if no elements were added, {@code getFrom()} is equal to {@code getTo()}.
57 * <p>It is possible to get a list of added elements by calling getAddedSubList().
58 * <p>Note that in order to maintain correct indexes of the separate add/remove changes, these changes
59 * <b>must</b> be sorted by their {@code from} index.
60 * <li><b>Update change</b> : {@link #wasUpdated()} return true on an update change.
61 * All elements between {@link #getFrom() from}(inclusive) and {@link #getTo() to}(exclusive) were updated.
62 * </ul>
63 *
64 * <b>Important:</b> It's necessary to call {@link #next()} method before calling
65 * any other method of {@code Change}. The same applies after calling {@link #reset()}.
66 * The only methods that works at any time is {@link #getList()}.
67 *
68 *<p>
69 * Typical usage is to observe changes on an ObservableList in order
70 * to hook or unhook (or add or remove a listener) or in order to maintain
71 * some invariant on every element in that ObservableList. A common code
72 * pattern for doing this looks something like the following:<br>
73 *
74 * <blockquote><pre>
75 * ObservableList<Item> theList = ...;
76 *
77 * theList.addListener(new ListChangeListener<Item>() {
78 * public void onChanged(Change<tem> c) {
79 * while (c.next()) {
80 * if (c.wasPermutated()) {
81 * for (int i = c.getFrom(); i < c.getTo(); ++i) {
82 * //permutate
83 * }
84 * } else if (c.wasUpdated()) {
85 * //update item
86 * } else {
87 * for (Item remitem : c.getRemoved()) {
88 * remitem.remove(Outer.this);
89 * }
90 * for (Item additem : c.getAddedSubList()) {
91 * additem.add(Outer.this);
92 * }
93 * }
94 * }
95 * }
|
55 * denotes the sublist of the list that contain new elements. Note that this is a half-open
56 * interval, so if no elements were added, {@code getFrom()} is equal to {@code getTo()}.
57 * <p>It is possible to get a list of added elements by calling getAddedSubList().
58 * <p>Note that in order to maintain correct indexes of the separate add/remove changes, these changes
59 * <b>must</b> be sorted by their {@code from} index.
60 * <li><b>Update change</b> : {@link #wasUpdated()} return true on an update change.
61 * All elements between {@link #getFrom() from}(inclusive) and {@link #getTo() to}(exclusive) were updated.
62 * </ul>
63 *
64 * <b>Important:</b> It's necessary to call {@link #next()} method before calling
65 * any other method of {@code Change}. The same applies after calling {@link #reset()}.
66 * The only methods that works at any time is {@link #getList()}.
67 *
68 *<p>
69 * Typical usage is to observe changes on an ObservableList in order
70 * to hook or unhook (or add or remove a listener) or in order to maintain
71 * some invariant on every element in that ObservableList. A common code
72 * pattern for doing this looks something like the following:<br>
73 *
74 * <blockquote><pre>
75 * ObservableList<Item> theList = ...;
76 *
77 * theList.addListener(new ListChangeListener<Item>() {
78 * public void onChanged(Change<tem> c) {
79 * while (c.next()) {
80 * if (c.wasPermutated()) {
81 * for (int i = c.getFrom(); i < c.getTo(); ++i) {
82 * //permutate
83 * }
84 * } else if (c.wasUpdated()) {
85 * //update item
86 * } else {
87 * for (Item remitem : c.getRemoved()) {
88 * remitem.remove(Outer.this);
89 * }
90 * for (Item additem : c.getAddedSubList()) {
91 * additem.add(Outer.this);
92 * }
93 * }
94 * }
95 * }
|