[1126] | 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.ITaskTreeNode; |
---|
| 19 | |
---|
| 20 | /** |
---|
| 21 | * TODO comment |
---|
| 22 | * |
---|
| 23 | * @version $Revision: $ $Date: 19.02.2012$ |
---|
| 24 | * @author 2012, last modified by $Author: patrick$ |
---|
| 25 | */ |
---|
| 26 | public class Optional extends TaskTreeNode implements IOptional { |
---|
| 27 | |
---|
| 28 | /** |
---|
| 29 | * |
---|
| 30 | */ |
---|
| 31 | Optional() { |
---|
| 32 | super("Optional"); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | /* |
---|
| 36 | * (non-Javadoc) |
---|
| 37 | * |
---|
| 38 | * @see de.ugoe.cs.tasktree.treeifc.TaskTreeNode#addChild(TaskTreeNode) |
---|
| 39 | */ |
---|
| 40 | @Override |
---|
| 41 | public void addChild(ITaskTreeNode child) { |
---|
| 42 | // adding more children is not allowed |
---|
| 43 | throw new UnsupportedOperationException |
---|
| 44 | ("optionalities may not have a list of children. Use setChild() instead."); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | /** |
---|
| 48 | * TODO: comment |
---|
| 49 | * |
---|
| 50 | * @param selection |
---|
| 51 | * @return |
---|
| 52 | */ |
---|
| 53 | public void setChild(ITaskTreeNode child) { |
---|
| 54 | if (super.getChildren().size() > 0) { |
---|
| 55 | super.removeChild(0); |
---|
| 56 | } |
---|
| 57 | super.addChild(child); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /* |
---|
| 61 | * (non-Javadoc) |
---|
| 62 | * |
---|
| 63 | * @see java.lang.Object#clone() |
---|
| 64 | */ |
---|
| 65 | @Override |
---|
| 66 | public Optional clone() { |
---|
| 67 | return (Optional) super.clone(); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | } |
---|