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