Changeset 1733 for branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/IterationInstance.java
- Timestamp:
- 09/05/14 19:33:12 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/IterationInstance.java
r1414 r1733 33 33 class IterationInstance extends TaskInstance implements IIterationInstance { 34 34 35 36 37 38 39 40 35 /** 36 * <p> 37 * default serial version UID 38 * </p> 39 */ 40 private static final long serialVersionUID = 1L; 41 41 42 43 44 45 46 47 42 /** 43 * <p> 44 * the children of this task instance which are task instances, as well 45 * </p> 46 */ 47 private List<ITaskInstance> children; 48 48 49 /** 50 * <p> 51 * initializes this instance with the respective task model 52 * </p> 53 * 54 * @param task the task of which this is an instance 55 */ 56 IterationInstance(IIteration task) { 57 super(task); 58 } 49 /** 50 * <p> 51 * initializes this instance with the respective task model 52 * </p> 53 * 54 * @param task 55 * the task of which this is an instance 56 */ 57 IterationInstance(IIteration task) { 58 super(task); 59 } 59 60 60 /* (non-Javadoc) 61 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance#getChildren() 62 */ 63 public synchronized List<ITaskInstance> getChildren() { 64 if (children == null) { 65 children = new LinkedList<ITaskInstance>(); 66 } 61 /** 62 * <p> 63 * used to add a child to this task instance at a specific position 64 * </p> 65 * 66 * @param index 67 * the position of the new child in the list of children 68 * @param child 69 * the new child of this instance 70 */ 71 synchronized void addChild(int index, ITaskInstance child) { 72 if (children == null) { 73 children = new LinkedList<ITaskInstance>(); 74 } 67 75 68 return Collections.unmodifiableList(children);69 76 children.add(index, child); 77 } 70 78 71 /* (non-Javadoc) 72 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#get(int) 73 */ 74 @Override 75 public ITaskInstance get(int index) { 76 if (children == null) { 77 throw new IndexOutOfBoundsException(Integer.toString(index)); 78 } 79 else{80 return children.get(index); 81 } 82 79 /** 80 * <p> 81 * used to add a child to this task instance 82 * </p> 83 * 84 * @param child 85 * the new child of this instance 86 */ 87 synchronized void addChild(ITaskInstance child) { 88 if (children == null) { 89 children = new LinkedList<ITaskInstance>(); 90 } 83 91 84 /* (non-Javadoc) 85 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#size() 86 */ 87 @Override 88 public int size() { 89 if (children == null) { 90 return 0; 91 } 92 else { 93 return children.size(); 94 } 95 } 92 children.add(child); 93 } 96 94 97 /* (non-Javadoc) 98 * @see java.lang.Iterable#iterator() 99 */ 100 @Override 101 public Iterator<ITaskInstance> iterator() { 102 return getChildren().iterator(); 103 } 95 /* 96 * (non-Javadoc) 97 * 98 * @see de.ugoe.cs.autoquest.tasktrees.treeimpl.IIterationInstance#clone() 99 */ 100 @Override 101 public synchronized IIterationInstance clone() { 102 final IterationInstance clone = (IterationInstance) super.clone(); 104 103 105 /* (non-Javadoc) 106 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance#getIteration() 107 */ 108 @Override 109 public IIteration getIteration() { 110 return (IIteration) super.getTask(); 111 } 104 if (children != null) { 105 clone.children = new LinkedList<ITaskInstance>(); 112 106 113 /* (non-Javadoc) 114 * @see de.ugoe.cs.autoquest.tasktrees.treeimpl.IIterationInstance#clone() 115 */ 116 @Override 117 public synchronized IIterationInstance clone() { 118 IterationInstance clone = (IterationInstance) super.clone(); 107 for (final ITaskInstance child : children) { 108 clone.children.add(child.clone()); 109 } 110 } 119 111 120 if (children != null) { 121 clone.children = new LinkedList<ITaskInstance>(); 112 return clone; 113 } 122 114 123 for (ITaskInstance child : children) { 124 clone.children.add(child.clone()); 125 } 126 } 115 /* 116 * (non-Javadoc) 117 * 118 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#get(int) 119 */ 120 @Override 121 public ITaskInstance get(int index) { 122 if (children == null) { 123 throw new IndexOutOfBoundsException(Integer.toString(index)); 124 } else { 125 return children.get(index); 126 } 127 } 127 128 128 return clone; 129 } 129 /* 130 * (non-Javadoc) 131 * 132 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance#getChildren() 133 */ 134 public synchronized List<ITaskInstance> getChildren() { 135 if (children == null) { 136 children = new LinkedList<ITaskInstance>(); 137 } 130 138 131 /** 132 * <p> 133 * used to add a child to this task instance 134 * </p> 135 * 136 * @param child the new child of this instance 137 */ 138 synchronized void addChild(ITaskInstance child) { 139 if (children == null) { 140 children = new LinkedList<ITaskInstance>(); 141 } 139 return Collections.unmodifiableList(children); 140 } 142 141 143 children.add(child); 144 } 142 /* 143 * (non-Javadoc) 144 * 145 * @see 146 * de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance#getIteration() 147 */ 148 @Override 149 public IIteration getIteration() { 150 return (IIteration) super.getTask(); 151 } 145 152 146 /** 147 * <p> 148 * used to add a child to this task instance at a specific position 149 * </p> 150 * 151 * @param index the position of the new child in the list of children 152 * @param child the new child of this instance 153 */ 154 synchronized void addChild(int index, ITaskInstance child) { 155 if (children == null) { 156 children = new LinkedList<ITaskInstance>(); 157 } 153 /* 154 * (non-Javadoc) 155 * 156 * @see java.lang.Iterable#iterator() 157 */ 158 @Override 159 public Iterator<ITaskInstance> iterator() { 160 return getChildren().iterator(); 161 } 158 162 159 children.add(index, child); 160 } 163 /** 164 * <p> 165 * removes a child from this task instance at a specific position 166 * </p> 167 * 168 * @param index 169 * the position of the child to be removed 170 * 171 * @return the child removed from the children of this instance 172 */ 173 synchronized ITaskInstance removeChild(int index) { 174 if (children != null) { 175 return children.remove(index); 176 } else { 177 throw new IllegalArgumentException( 178 "this task instance does not have children that can be removed"); 179 } 180 } 161 181 162 /** 163 * <p> 164 * removes a child from this task instance at a specific position 165 * </p> 166 * 167 * @param index the position of the child to be removed 168 * 169 * @return the child removed from the children of this instance 170 */ 171 synchronized ITaskInstance removeChild(int index) { 172 if (children != null) { 173 return children.remove(index); 174 } 175 else { 176 throw new IllegalArgumentException 177 ("this task instance does not have children that can be removed"); 178 } 179 } 182 /* 183 * (non-Javadoc) 184 * 185 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#size() 186 */ 187 @Override 188 public int size() { 189 if (children == null) { 190 return 0; 191 } else { 192 return children.size(); 193 } 194 } 180 195 181 196 }
Note: See TracChangeset
for help on using the changeset viewer.