source: branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/StructuringTemporalRelationship.java @ 1733

Last change on this file since 1733 was 1733, checked in by rkrimmel, 10 years ago

Used Eclipse code cleanup

File size: 3.3 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
26 * {@link IStructuringTemporalRelationship}. It does not do anything fancy
27 * except implementing the interface.
28 * </p>
29 *
30 * @author Patrick Harms
31 */
32abstract class StructuringTemporalRelationship extends Task implements
33                IStructuringTemporalRelationship {
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
55         *            the human readable name of this temporal relationship
56         */
57        StructuringTemporalRelationship(String relationshipType) {
58                super(relationshipType);
59
60                if ((relationshipType == null) || ("".equals(relationshipType))) {
61                        throw new IllegalArgumentException(
62                                        "the relationship type must be something meaningful");
63                }
64        }
65
66        /**
67         * <p>
68         * used to add a new child to this temporal relationship at a specific
69         * position.
70         * </p>
71         *
72         * @param index
73         *            the index of the new child to be added.
74         * @param newChild
75         *            the new child to be added
76         */
77        void addChild(int index, ITask newChild) {
78                children.add(index, newChild);
79        }
80
81        /**
82         * <p>
83         * used to add a new child to this temporal relationship.
84         * </p>
85         *
86         * @param newChild
87         *            the new child to be added
88         */
89        void addChild(ITask newChild) {
90                children.add(newChild);
91        }
92
93        /*
94         * (non-Javadoc)
95         *
96         * @see de.ugoe.cs.autoquest.tasktrees.treeimpl.Task#clone()
97         */
98        @Override
99        public synchronized StructuringTemporalRelationship clone() {
100                StructuringTemporalRelationship clone = null;
101                clone = (StructuringTemporalRelationship) super.clone();
102
103                clone.children = new LinkedList<ITask>();
104
105                for (final ITask child : this.children) {
106                        clone.children.add(child.clone());
107                }
108
109                return clone;
110        }
111
112        /*
113         * (non-Javadoc)
114         *
115         * @see
116         * de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship
117         * #getChildren()
118         */
119        @Override
120        public List<ITask> getChildren() {
121                return children;
122        }
123
124        /**
125         * <p>
126         * removes a child from this temporal relationship at a specific position.
127         * </p>
128         *
129         * @param index
130         *            the index of the child to be removed.
131         */
132        void removeChild(int index) {
133                children.remove(index);
134        }
135}
Note: See TracBrowser for help on using the repository browser.