Changeset 1294 for trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInstance.java
- Timestamp:
- 08/14/13 17:04:42 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInstance.java
r1255 r1294 14 14 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 17 import java.util.Collections;18 import java.util.Iterator;19 import java.util.LinkedList;20 import java.util.List;21 16 22 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; … … 64 59 /** 65 60 * <p> 66 * the children of this task instance which are task instances, as well67 * </p>68 */69 private List<ITaskInstance> children;70 71 /**72 * <p>73 61 * instantiated the task instance with the task that is instantiated by the instance. It also 74 62 * assigns a unique id to the instance using {@link #getNewId()}. … … 102 90 public ITask getTask() { 103 91 return task; 104 }105 106 /* (non-Javadoc)107 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance#getChildren()108 */109 public synchronized List<ITaskInstance> getChildren() {110 if (children == null) {111 children = new LinkedList<ITaskInstance>();112 }113 114 return Collections.unmodifiableList(children);115 }116 117 /* (non-Javadoc)118 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#get(int)119 */120 @Override121 public ITaskInstance get(int index) {122 if (children == null) {123 throw new IndexOutOfBoundsException(Integer.toString(index));124 }125 else {126 return children.get(index);127 }128 }129 130 /* (non-Javadoc)131 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#size()132 */133 @Override134 public int size() {135 if (children == null) {136 return 0;137 }138 else {139 return children.size();140 }141 }142 143 /* (non-Javadoc)144 * @see java.lang.Iterable#iterator()145 */146 @Override147 public Iterator<ITaskInstance> iterator() {148 return getChildren().iterator();149 92 } 150 93 … … 203 146 try { 204 147 clone = (TaskInstance) super.clone(); 205 206 if (children != null) {207 clone.children = new LinkedList<ITaskInstance>();208 209 for (ITaskInstance child : children) {210 clone.children.add(child.clone());211 }212 }213 214 148 } 215 149 catch (CloneNotSupportedException e) { … … 219 153 220 154 return clone; 221 }222 223 /**224 * <p>225 * used to add a child to this task instance226 * </p>227 *228 * @param child the new child of this instance229 */230 synchronized void addChild(ITaskInstance child) {231 if (children == null) {232 children = new LinkedList<ITaskInstance>();233 }234 235 children.add(child);236 }237 238 /**239 * <p>240 * used to add a child to this task instance at a specific position241 * </p>242 *243 * @param index the position of the new child in the list of children244 * @param child the new child of this instance245 */246 synchronized void addChild(int index, ITaskInstance child) {247 if (children == null) {248 children = new LinkedList<ITaskInstance>();249 }250 251 children.add(index, child);252 }253 254 /**255 * <p>256 * removes a child from this task instance at a specific position257 * </p>258 *259 * @param index the position of the child to be removed260 *261 * @return the child remove from the children of this instance262 */263 synchronized ITaskInstance removeChild(int index) {264 if (children != null) {265 return children.remove(index);266 }267 else {268 throw new IllegalArgumentException269 ("this task instance does not have children that can be removed");270 }271 155 } 272 156
Note: See TracChangeset
for help on using the changeset viewer.