Changeset 1891 for trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInfo.java
- Timestamp:
- 03/05/15 11:43:42 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInfo.java
r1428 r1891 16 16 17 17 import java.util.ArrayList; 18 import java.util.HashMap;19 18 20 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; … … 89 88 90 89 /* (non-Javadoc) 91 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo#getMeasureValue(java.lang.String, de.ugoe.cs.autoquest.tasktrees.treeifc.ITask)92 */93 @Override94 public int getMeasureValue(TaskMetric metric, ITask context) {95 Measure measure = getMeasure(metric);96 97 if (measure == null) {98 throw new IllegalArgumentException("unknown metric " + metric);99 }100 101 return measure.getValue(context);102 }103 104 /* (non-Javadoc)105 90 * @see java.lang.Object#toString() 106 91 */ … … 112 97 /** 113 98 * <p> 114 * must be called to indicate that a newnew measures for the provided metric are about to99 * must be called to indicate that new measures for the provided metric are about to 115 100 * be calculated and added. 116 101 * </p> … … 131 116 /** 132 117 * <p> 133 * sets a specific value for a measure of a specific metric in the provided context of the task118 * sets a specific value for a measure of a specific metric 134 119 * </p> 135 120 * 136 121 * @param metric the metric to which the value belongs 137 * @param context the context of the task in which the measure was recorded138 122 * @param value the value of the measure 139 123 */ 140 void setCount(TaskMetric metric, ITask context,int value) {124 void setCount(TaskMetric metric, int value) { 141 125 Measure measure = getMeasure(metric); 142 126 … … 146 130 } 147 131 148 measure.set(context, value); 149 } 150 151 /** 152 * <p> 153 * increases a specific value for a measure of a specific metric in the provided context of the 154 * task 132 measure.set(value); 133 } 134 135 /** 136 * <p> 137 * increases a specific value for a measure of a specific metric 155 138 * </p> 156 139 * 157 140 * @param metric the metric to which the value belongs 158 * @param context the context of the task in which the measure was recorded159 141 * @param increment the increment to be added to the value of the measure 160 142 */ 161 void increaseCount(TaskMetric metric, ITask context,int increment) {143 void increaseCount(TaskMetric metric, int increment) { 162 144 Measure measure = getMeasure(metric); 163 145 … … 167 149 } 168 150 169 measure.increase( context,increment);151 measure.increase(increment); 170 152 } 171 153 … … 204 186 /** 205 187 * <p> 206 * the observed values for the difference contexts of the task 207 * </p> 208 */ 209 private HashMap<ITask, Integer> values; 210 211 /** 212 * <p> 213 * the context free value of the measure independent of the task context 214 * </p> 215 */ 216 private int contextFreeValue = 0; 188 * the value of the measure independent 189 * </p> 190 */ 191 private int value = 0; 217 192 218 193 /** … … 239 214 @Override 240 215 public int getValue() { 241 return contextFreeValue; 242 } 243 244 /* (non-Javadoc) 245 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo.IMeasure#getValue(de.ugoe.cs.autoquest.tasktrees.treeifc.ITask) 246 */ 247 @Override 248 public int getValue(ITask context) { 249 if ((context != null) && (values != null)) { 250 Integer currentValue = values.get(context); 251 252 if (currentValue != null) { 253 return currentValue; 254 } 255 } 256 257 return Integer.MIN_VALUE; 258 } 259 260 /** 261 * <p> 262 * sets the value of the measure context free as well as specific to the provided context 263 * </p> 264 */ 265 private void set(ITask context, int value) { 266 contextFreeValue = value; 267 268 if (context != null) { 269 if (values == null) { 270 values = new HashMap<ITask, Integer>(); 271 } 272 273 values.put(context, value); 274 } 275 } 276 277 /** 278 * <p> 279 * increases the value of the measure context free as well as specific to the provided 280 * context according to the provided increment 281 * </p> 282 */ 283 private void increase(ITask context, int increment) { 284 contextFreeValue += increment; 285 286 if (context != null) { 287 if (values == null) { 288 values = new HashMap<ITask, Integer>(); 289 } 290 291 Integer currentValue = values.get(context); 292 293 if (currentValue == null) { 294 currentValue = 0; 295 } 296 297 values.put(context, currentValue + increment); 298 } 216 return value; 217 } 218 219 /** 220 * <p> 221 * sets the value of the measure 222 * </p> 223 */ 224 private void set(int newValue) { 225 value = newValue; 226 } 227 228 /** 229 * <p> 230 * increases the value of the measure 231 * </p> 232 */ 233 private void increase(int increment) { 234 value += increment; 299 235 } 300 236
Note: See TracChangeset
for help on using the changeset viewer.