[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> |
---|
[1215] | 25 | * this is the default implementation of the interface {@link IStructuringTemporalRelationship}. It |
---|
| 26 | * does not do anything fancy except implementing the interface. |
---|
[1146] | 27 | * </p> |
---|
| 28 | * |
---|
| 29 | * @author Patrick Harms |
---|
| 30 | */ |
---|
| 31 | abstract class StructuringTemporalRelationship extends Task |
---|
| 32 | implements IStructuringTemporalRelationship |
---|
| 33 | { |
---|
| 34 | |
---|
[1215] | 35 | /** |
---|
| 36 | * <p> |
---|
| 37 | * default serial version UID |
---|
| 38 | * </p> |
---|
| 39 | */ |
---|
[1146] | 40 | private static final long serialVersionUID = 1L; |
---|
| 41 | |
---|
| 42 | /** |
---|
[1215] | 43 | * <p> |
---|
| 44 | * the list of children of this temporal relationship |
---|
| 45 | * </p> |
---|
[1146] | 46 | */ |
---|
| 47 | private List<ITask> children = new LinkedList<ITask>(); |
---|
| 48 | |
---|
| 49 | /** |
---|
| 50 | * <p> |
---|
[1215] | 51 | * initializes this temporal relationship with a human readable name |
---|
[1146] | 52 | * </p> |
---|
| 53 | * |
---|
[1215] | 54 | * @param relationshipType the human readable name of this temporal relationship |
---|
[1146] | 55 | */ |
---|
| 56 | StructuringTemporalRelationship(String relationshipType) { |
---|
[1357] | 57 | super(relationshipType); |
---|
| 58 | |
---|
[1146] | 59 | if ((relationshipType == null) || ("".equals(relationshipType))) { |
---|
| 60 | throw new IllegalArgumentException |
---|
| 61 | ("the relationship type must be something meaningful"); |
---|
| 62 | } |
---|
| 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> |
---|
[1215] | 92 | * used to add a new child to this temporal relationship. |
---|
[1146] | 93 | * </p> |
---|
| 94 | * |
---|
[1215] | 95 | * @param newChild the new child to be added |
---|
[1146] | 96 | */ |
---|
[1215] | 97 | void addChild(ITask newChild) { |
---|
[1146] | 98 | children.add(newChild); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | /** |
---|
| 102 | * <p> |
---|
[1215] | 103 | * used to add a new child to this temporal relationship at a specific position. |
---|
[1146] | 104 | * </p> |
---|
| 105 | * |
---|
[1215] | 106 | * @param index the index of the new child to be added. |
---|
| 107 | * @param newChild the new child to be added |
---|
[1146] | 108 | */ |
---|
[1215] | 109 | void addChild(int index, ITask newChild) { |
---|
[1146] | 110 | children.add(index, newChild); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | /** |
---|
| 114 | * <p> |
---|
[1215] | 115 | * removes a child from this temporal relationship at a specific position. |
---|
[1146] | 116 | * </p> |
---|
| 117 | * |
---|
[1215] | 118 | * @param index the index of the child to be removed. |
---|
[1146] | 119 | */ |
---|
| 120 | void removeChild(int index) { |
---|
| 121 | children.remove(index); |
---|
| 122 | } |
---|
| 123 | } |
---|