Changeset 1362


Ignore:
Timestamp:
02/07/14 19:09:08 (10 years ago)
Author:
pharms
Message:
  • prevented a Nullpointer
  • corrected removal of instances of a task in case an instance is assigned a new task
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskBuilder.java

    r1294 r1362  
    192192        if (!(instance instanceof SelectionInstance)) { 
    193193            throw new IllegalArgumentException 
    194                 ("illegal type of sequence instance provided: " + instance.getClass()); 
     194                ("illegal type of selection instance provided: " + instance.getClass()); 
    195195        } 
    196196 
    197197        if (!(child instanceof TaskInstance)) { 
    198             throw new IllegalArgumentException 
    199                 ("illegal type of task instance provided: " + child.getClass()); 
     198            throw new IllegalArgumentException("illegal type of task instance provided: " + 
     199                                               (child == null ? null : child.getClass())); 
    200200        } 
    201201         
     
    353353                ("illegal type of task instance provided: " + taskInstance.getClass()); 
    354354        } 
    355          
     355        if (!(task instanceof Task)) { 
     356            throw new IllegalArgumentException("illegal type of task provided: " + task.getClass()); 
     357        } 
     358         
     359        if (((TaskInstance) taskInstance).getTask() instanceof Task) { 
     360            ((Task) ((TaskInstance) taskInstance).getTask()).removeInstance(taskInstance); 
     361        } 
    356362        ((TaskInstance) taskInstance).setTask(task); 
     363         
     364        ((Task) task).addInstance(taskInstance); 
    357365    } 
    358366 
Note: See TracChangeset for help on using the changeset viewer.