source: trunk/autoquest-generic-event-monitor/src/main/java/de/ugoe/cs/autoquest/genericeventmonitor/GenericEventTarget.java @ 2155

Last change on this file since 2155 was 2155, checked in by pharms, 7 years ago
  • Property svn:mime-type set to text/plain
File size: 2.9 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.genericeventmonitor;
16
17import java.util.ArrayList;
18import java.util.List;
19import java.util.Map;
20
21/**
22 * <p>
23 * a generic representation of event target. An event target has an id, optionally a parent or a
24 * list of children, and parameters.
25 * </p>
26 *
27 * @author Patrick Harms
28 */
29class GenericEventTarget {
30
31    /** the id of the target */
32    private String targetId;
33
34    /** the parameters of the target providing further important target details */
35    private Map<String, String> parameters;
36
37    /** if available the parent of the given target (used for creating target hierarchies) */
38    private GenericEventTarget parent;
39
40    /** if available the children of the given target (used for creating target hierarchies) */
41    private List<GenericEventTarget> children = null;
42
43    /**
44     * <p>
45     * initialized the generic event target with an id, the parameters and a parent if any. All
46     * parameters may be null.
47     * </p>
48     *
49     * @param targetId   the id of the target
50     * @param parameters the parameters to provide further target details
51     * @param parent     if available the parent of the given target
52     */
53    GenericEventTarget(String              targetId,
54                       Map<String, String> parameters,
55                       GenericEventTarget  parent)
56    {
57        this.targetId = targetId;
58        this.parameters = parameters;
59        this.parent = parent;
60    }
61
62    /**
63     * <p>
64     * used to add a child to this target
65     * </p>
66     *
67     * @param child the new child of this event target
68     */
69    synchronized void addChild(GenericEventTarget child) {
70        if (children == null) {
71            children = new ArrayList<>();
72        }
73       
74        this.children.add(child);
75    }
76
77    /**
78     * @return the targetId
79     */
80    String getId() {
81        return targetId;
82    }
83
84    /**
85     * @return the parameters
86     */
87    Map<String, String> getParameters() {
88        return parameters;
89    }
90
91    /**
92     * @return the parent
93     */
94    GenericEventTarget getParent() {
95        return parent;
96    }
97
98    /**
99     * @return the children
100     */
101    List<GenericEventTarget> getChildren() {
102        return children;
103    }
104
105    /**
106     *
107     */
108    @Override
109    public String toString() {
110        return targetId;
111    }
112}
Note: See TracBrowser for help on using the repository browser.