comparison org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/ListDiffVisitor.d @ 78:0a55d2d5a946

Added file for databinding
author Frank Benoit <benoit@tionex.de>
date Tue, 14 Apr 2009 11:35:29 +0200
parents
children
comparison
equal deleted inserted replaced
76:f05e6e8b2f2d 78:0a55d2d5a946
1 /*******************************************************************************
2 * Copyright (c) 2007 Matthew Hall and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Matthew Hall - initial API and implementation (bug 208858)
10 ******************************************************************************/
11
12 module org.eclipse.core.databinding.observable.list.ListDiffVisitor;
13
14 import java.lang.all;
15
16 import java.util.List;
17
18 /**
19 * A visitor for processing differences in a ListDiff.
20 *
21 * @see ListDiff#acceptcast(ListDiffVisitor)
22 * @since 1.1
23 */
24 public abstract class ListDiffVisitor {
25 /**
26 * Notifies the visitor that <code>element</code> was added to the list at
27 * position <code>index</code>.
28 *
29 * @param index
30 * the index where the element was added
31 * @param element
32 * the element that was added
33 */
34 public abstract void handleAdd(int index, Object element);
35
36 /**
37 * Notifies the visitor that <code>element</code> was removed from the
38 * list at position <code>index</code>.
39 *
40 * @param index
41 * the index where the element was removed
42 * @param element
43 * the element that was removed
44 */
45 public abstract void handleRemove(int index, Object element);
46
47 /**
48 * Notifies the visitor that <code>element</code> was moved in the list
49 * from position <code>oldIndex</code> to position <code>newIndex</code>.
50 * <p>
51 * The default implementation of this method calls
52 * {@link #handleRemove(int, Object)} with the old position, then
53 * {@link #handleAdd(int, Object)} with the new position. Clients which are
54 * interested in recognizing "moves" in a list (i.e. calls to
55 * {@link IObservableList#move(int, int)}) should override this method.
56 *
57 * @param oldIndex
58 * the index that the element was moved from.
59 * @param newIndex
60 * the index that the element was moved to.
61 * @param element
62 * the element that was moved
63 * @see IObservableList#move(int, int)
64 */
65 public void handleMove(int oldIndex, int newIndex, Object element) {
66 handleRemove(oldIndex, element);
67 handleAdd(newIndex, element);
68 }
69
70 /**
71 * Notifies the visitor that <code>oldElement</code>, located at position
72 * <code>index</code> in the list, was replaced by <code>newElement</code>.
73 * <p>
74 * The default implementation of this method calls
75 * {@link #handleRemove(int, Object)} with the old element, then
76 * {@link #handleAdd(int, Object)} with the new element. Clients which are
77 * interested in recognizing "replaces" in a list (i.e. calls to
78 * {@link List#set(int, Object)}) should override this method.
79 *
80 * @param index
81 * the index where the element was replaced.
82 * @param oldElement
83 * the element being replaced.
84 * @param newElement
85 * the element that replaced oldElement.
86 * @see List#set(int, Object)
87 */
88 public void handleReplace(int index, Object oldElement, Object newElement) {
89 handleRemove(index, oldElement);
90 handleAdd(index, newElement);
91 }
92 }