[1294] | 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 de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; |
---|
| 18 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; |
---|
| 19 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
| 20 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; |
---|
| 21 | |
---|
| 22 | /** |
---|
| 23 | * <p> |
---|
[1414] | 24 | * Default implementation of {@link ISelectionInstance}. |
---|
[1294] | 25 | * </p> |
---|
| 26 | * |
---|
| 27 | * @author Patrick Harms |
---|
| 28 | */ |
---|
| 29 | class SelectionInstance extends TaskInstance implements ISelectionInstance { |
---|
| 30 | |
---|
[1733] | 31 | /** |
---|
| 32 | * <p> |
---|
| 33 | * default serial version UID |
---|
| 34 | * </p> |
---|
| 35 | */ |
---|
| 36 | private static final long serialVersionUID = 1L; |
---|
[1294] | 37 | |
---|
[1733] | 38 | /** |
---|
| 39 | * <p> |
---|
| 40 | * the child of this task instance |
---|
| 41 | * </p> |
---|
| 42 | */ |
---|
| 43 | private ITaskInstance child; |
---|
[1294] | 44 | |
---|
[1733] | 45 | /** |
---|
| 46 | * <p> |
---|
| 47 | * initializes this instance with the respective task model |
---|
| 48 | * </p> |
---|
| 49 | * |
---|
| 50 | * @param task |
---|
| 51 | * the task of which this is an instance |
---|
| 52 | */ |
---|
| 53 | SelectionInstance(ITask task) { |
---|
| 54 | super(task); |
---|
| 55 | } |
---|
[1294] | 56 | |
---|
[1733] | 57 | /* |
---|
| 58 | * (non-Javadoc) |
---|
| 59 | * |
---|
| 60 | * @see de.ugoe.cs.autoquest.tasktrees.treeimpl.ISequenceInstance#clone() |
---|
| 61 | */ |
---|
| 62 | @Override |
---|
| 63 | public synchronized ISelectionInstance clone() { |
---|
| 64 | final SelectionInstance clone = (SelectionInstance) super.clone(); |
---|
[1294] | 65 | |
---|
[1733] | 66 | if (child != null) { |
---|
| 67 | clone.child = child.clone(); |
---|
| 68 | } |
---|
[1294] | 69 | |
---|
[1733] | 70 | return clone; |
---|
| 71 | } |
---|
[1294] | 72 | |
---|
[1733] | 73 | /* |
---|
| 74 | * (non-Javadoc) |
---|
| 75 | * |
---|
| 76 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance#getChild() |
---|
| 77 | */ |
---|
| 78 | @Override |
---|
| 79 | public ITaskInstance getChild() { |
---|
| 80 | return child; |
---|
| 81 | } |
---|
[1294] | 82 | |
---|
[1733] | 83 | /* |
---|
| 84 | * (non-Javadoc) |
---|
| 85 | * |
---|
| 86 | * @see |
---|
| 87 | * de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance#getSelection() |
---|
| 88 | */ |
---|
| 89 | @Override |
---|
| 90 | public ISelection getSelection() { |
---|
| 91 | return (ISelection) super.getTask(); |
---|
| 92 | } |
---|
[1294] | 93 | |
---|
[1733] | 94 | /** |
---|
| 95 | * <p> |
---|
| 96 | * used to set the child of this task instance |
---|
| 97 | * </p> |
---|
| 98 | * |
---|
| 99 | * @param child |
---|
| 100 | * the new child of this instance |
---|
| 101 | */ |
---|
| 102 | void setChild(ITaskInstance child) { |
---|
| 103 | if (child instanceof ISelectionInstance) { |
---|
| 104 | throw new IllegalArgumentException( |
---|
| 105 | "the child of a selection can not be a selection"); |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | this.child = child; |
---|
| 109 | } |
---|
| 110 | |
---|
[1294] | 111 | } |
---|