source: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/StructuringTemporalRelationship.java @ 1215

Last change on this file since 1215 was 1215, checked in by pharms, 11 years ago
  • improved java doc
File size: 3.5 KB
Line 
1//   Copyright 2012 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.tasktrees.treeimpl;
16
17import java.util.LinkedList;
18import java.util.List;
19
20import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship;
21import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
22
23/**
24 * <p>
25 * this is the default implementation of the interface {@link IStructuringTemporalRelationship}. It
26 * does not do anything fancy except implementing the interface.
27 * </p>
28 *
29 * @author Patrick Harms
30 */
31abstract class StructuringTemporalRelationship extends Task
32    implements IStructuringTemporalRelationship
33{
34
35    /**
36     * <p>
37     * default serial version UID
38     * </p>
39     */
40    private static final long serialVersionUID = 1L;
41   
42    /**
43     * <p>
44     * the list of children of this temporal relationship
45     * </p>
46     */
47    private List<ITask> children = new LinkedList<ITask>();
48
49    /**
50     * <p>
51     * initializes this temporal relationship with a human readable name
52     * </p>
53     *
54     * @param relationshipType the human readable name of this temporal relationship
55     */
56    StructuringTemporalRelationship(String relationshipType) {
57        if ((relationshipType == null) || ("".equals(relationshipType))) {
58            throw new IllegalArgumentException
59                ("the relationship type must be something meaningful");
60        }
61       
62        super.setDescription(relationshipType);
63    }
64
65    /* (non-Javadoc)
66     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship#getChildren()
67     */
68    @Override
69    public List<ITask> getChildren() {
70        return children;
71    }
72
73    /* (non-Javadoc)
74     * @see de.ugoe.cs.autoquest.tasktrees.treeimpl.Task#clone()
75     */
76    @Override
77    public synchronized StructuringTemporalRelationship clone() {
78        StructuringTemporalRelationship clone = null;
79        clone = (StructuringTemporalRelationship) super.clone();
80           
81        clone.children = new LinkedList<ITask>();
82       
83        for (ITask child : this.children) {
84            clone.children.add(child.clone());
85        }
86
87        return clone;
88    }
89
90    /**
91     * <p>
92     * used to add a new child to this temporal relationship.
93     * </p>
94     *
95     * @param newChild the new child to be added
96     */
97    void addChild(ITask newChild) {
98        children.add(newChild);
99    }
100
101    /**
102     * <p>
103     * used to add a new child to this temporal relationship at a specific position.
104     * </p>
105     *
106     * @param index    the index of the new child to be added.
107     * @param newChild the new child to be added
108     */
109    void addChild(int index, ITask newChild) {
110        children.add(index, newChild);
111    }
112   
113    /**
114     * <p>
115     * removes a child from this temporal relationship at a specific position.
116     * </p>
117     *
118     * @param index the index of the child to be removed.
119     */
120    void removeChild(int index) {
121        children.remove(index);
122    }
123}
Note: See TracBrowser for help on using the repository browser.