[1146] | 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 | |
---|
| 15 | package de.ugoe.cs.autoquest.tasktrees.treeimpl; |
---|
| 16 | |
---|
| 17 | import java.util.LinkedList; |
---|
| 18 | import java.util.List; |
---|
| 19 | |
---|
| 20 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; |
---|
| 21 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
| 22 | |
---|
| 23 | /** |
---|
| 24 | * <p> |
---|
| 25 | * TODO comment |
---|
| 26 | * </p> |
---|
| 27 | * |
---|
| 28 | * @author Patrick Harms |
---|
| 29 | */ |
---|
| 30 | abstract class StructuringTemporalRelationship extends Task |
---|
| 31 | implements IStructuringTemporalRelationship |
---|
| 32 | { |
---|
| 33 | |
---|
| 34 | /** */ |
---|
| 35 | private static final long serialVersionUID = 1L; |
---|
| 36 | |
---|
| 37 | /** |
---|
| 38 | * |
---|
| 39 | */ |
---|
| 40 | private List<ITask> children = new LinkedList<ITask>(); |
---|
| 41 | |
---|
| 42 | /** |
---|
| 43 | * <p> |
---|
| 44 | * TODO: comment |
---|
| 45 | * </p> |
---|
| 46 | * |
---|
| 47 | * @param description |
---|
| 48 | */ |
---|
| 49 | StructuringTemporalRelationship(String relationshipType) { |
---|
| 50 | if ((relationshipType == null) || ("".equals(relationshipType))) { |
---|
| 51 | throw new IllegalArgumentException |
---|
| 52 | ("the relationship type must be something meaningful"); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | super.setDescription(relationshipType); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | /* (non-Javadoc) |
---|
| 59 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship#getChildren() |
---|
| 60 | */ |
---|
| 61 | @Override |
---|
| 62 | public List<ITask> getChildren() { |
---|
| 63 | return children; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /* (non-Javadoc) |
---|
| 67 | * @see de.ugoe.cs.autoquest.tasktrees.treeimpl.Task#clone() |
---|
| 68 | */ |
---|
| 69 | @Override |
---|
| 70 | public synchronized StructuringTemporalRelationship clone() { |
---|
| 71 | StructuringTemporalRelationship clone = null; |
---|
| 72 | clone = (StructuringTemporalRelationship) super.clone(); |
---|
| 73 | |
---|
| 74 | clone.children = new LinkedList<ITask>(); |
---|
| 75 | |
---|
| 76 | for (ITask child : this.children) { |
---|
| 77 | clone.children.add(child.clone()); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | return clone; |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | /** |
---|
| 84 | * <p> |
---|
| 85 | * TODO: comment |
---|
| 86 | * </p> |
---|
| 87 | * |
---|
| 88 | * @param i |
---|
| 89 | * @param newChild |
---|
| 90 | */ |
---|
| 91 | public void addChild(ITask newChild) { |
---|
| 92 | children.add(newChild); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | /** |
---|
| 96 | * <p> |
---|
| 97 | * TODO: comment |
---|
| 98 | * </p> |
---|
| 99 | * |
---|
| 100 | * @param i |
---|
| 101 | * @param newChild |
---|
| 102 | */ |
---|
| 103 | public void addChild(int index, ITask newChild) { |
---|
| 104 | children.add(index, newChild); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | /** |
---|
| 108 | * <p> |
---|
| 109 | * TODO: comment |
---|
| 110 | * </p> |
---|
| 111 | * |
---|
| 112 | * @param index |
---|
| 113 | */ |
---|
| 114 | void removeChild(int index) { |
---|
| 115 | children.remove(index); |
---|
| 116 | } |
---|
| 117 | } |
---|