source: trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/IHierarchicalEventTargetModel.java @ 2252

Last change on this file since 2252 was 2146, checked in by pharms, 7 years ago
  • refactored GUI model so that hierarchical event target structures can also be used and created by plugins not being strictly for GUIs
  • Property svn:mime-type set to text/plain
File size: 4.7 KB
Line 
1//   Copyright 2015 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.eventcore;
16
17import java.util.List;
18
19/**
20 * <p>
21 * This interface can be used to wrap tree like event target structures. This allows rather
22 * flexible implementations of such structures and can either be rather concrete, e.g., for
23 * GUI models, or rather generic for any type of event target. The interface provides a way to
24 * traverse the target structure by retrieving a traverser.
25 * </p>
26 *
27 * @author Patrick Harms
28 */
29public interface IHierarchicalEventTargetModel<T extends IHierarchicalEventTarget>  {
30
31    /**
32     * <p>
33     * Returns all children of the provided event target or null, if it does not have any or the
34     * node is unknown.
35     * </p>
36     *
37     * @param eventTarget
38     *            the event target of which the children shall be returned
39     *
40     * @return As described
41     */
42    List<T> getChildren(T eventTarget);
43
44    /**
45     * <p>
46     * Returns the parent event target of the provided one or null, if it does not have a
47     * parent (i.e. if it is a root node) or if the node is unknown.
48     * </p>
49     *
50     * @param eventTarget
51     *            the event target of which the parent shall be returned
52     *
53     * @return As described
54     */
55    T getParent(T eventTarget);
56
57    /**
58     * <p>
59     * Returns all root event targets of the model or an empty list, if the model is empty
60     * </p>
61     *
62     * @return As described
63     */
64    List<T> getRootElements();
65
66   
67    /**
68     * returns a traverser for the event target model to have efficient access to the tree of
69     * event targets without having direct access.
70     *
71     * @return a traverser
72     */
73    Traverser<T> getTraverser();
74
75    /**
76     * returns a traverser for the event target model starting at the given event target. Returns
77     * null, if the event target is not part of the model.
78     *
79     * @return a traverser
80     */
81    Traverser<T> getTraverser(T startingAt);
82
83   
84    /**
85     * <p>
86     * This interface defines the methods to be provided by model traversers
87     * </p>
88     *
89     * @author Patrick Harms
90     */
91    public interface Traverser<T> {
92
93        /**
94         * <p>
95         * returns the first child of the current event target. On the first call of this method on
96         * the traverser the first of the root event targets of the event target model is returned.
97         * If the current event target does not have children, the method returns null. If the
98         * event target model is empty, then a call to this method will return null. The returned
99         * event target is the next one the traverser points to.
100         * </p>
101         *
102         * @return as described.
103         */
104        T firstChild();
105
106        /**
107         * <p>
108         * returns true, if the current event target has a first child, i.e. if the next call to the
109         * method {@link #firstChild()} would return an event target or null.
110         * </p>
111         *
112         * @return as described
113         */
114        boolean hasFirstChild();
115
116        /**
117         * <p>
118         * returns the next sibling of the current event target. If there is no further sibling,
119         * null is returned. If the current event target is one of the root nodes, the next root
120         * node of the event target model is returned. The returned event target is the next one
121         * the traverser points to.
122         * </p>
123         *
124         * @return as described
125         */
126        T nextSibling();
127
128        /**
129         * <p>
130         * returns true, if the current event target has a further sibling, i.e. if a call to the
131         * method {@link #nextSibling()} will return an event target
132         * </p>
133         *
134         * @return as described
135         */
136        boolean hasNextSibling();
137
138        /**
139         * <p>
140         * returns the parent event target of the current event target. If the current event target
141         * is a root node, null is returned. If there is no current event target yet as the method
142         * {@link #firstChild()} was not called yet, null is returned.
143         * </p>
144         *
145         * @return as described
146         */
147        T parent();
148
149    }
150}
Note: See TracBrowser for help on using the repository browser.