source: trunk/autoquest-plugin-usability2/src/main/java/de/ugoe/cs/autoquest/plugin/usability2/rules/operator/wrapper/AbstractTaskWrapper.java @ 1326

Last change on this file since 1326 was 1326, checked in by khartmann, 10 years ago

Moved alexanders code into a new plugin project.
First commit of my experimental code (needs a lot of cleanup).

File size: 2.8 KB
Line 
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
15package de.ugoe.cs.autoquest.plugin.usability2.rules.operator.wrapper;
16
17import java.util.ArrayList;
18import java.util.Collection;
19import java.util.Collections;
20import java.util.HashMap;
21import java.util.List;
22import java.util.Map;
23
24import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance;
25import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance;
27
28/**
29 * <p>
30 * TODO comment
31 * </p>
32 *
33 * @author Konni Hartmann
34 */
35public abstract class AbstractTaskWrapper implements ITaskWrapper {
36
37    /**  */
38    private static final long serialVersionUID = 1L;
39
40    Map<ITaskInstance, List<ITaskInstance>> instances =
41        new HashMap<ITaskInstance, List<ITaskInstance>>();
42
43    @Override
44    public void addFilteredInstance(ITaskInstance filter, ITaskInstance instance) {       
45        List<ITaskInstance> list = instances.get(filter);
46        if(list == null) {
47            list = new ArrayList<ITaskInstance>();
48            instances.put(filter, list);
49        }
50        list.add(instance);
51    }
52
53    @Override
54    public List<ITaskInstance> getFilteredInstances(ITaskInstance filter) {
55        return Collections.unmodifiableList(instances.get(filter));
56    }
57
58    public Map<ITaskInstance, List<ITaskInstance>> getFilteredInstances() {
59        return Collections.unmodifiableMap(instances);
60    }
61   
62    public Collection<List<IEventTaskInstance>> getInstanceSequences() {
63        GenerateInstanceListVisitor visitor = new GenerateInstanceListVisitor();
64        return visitor.generateInstanceList(this.getReference());
65    }
66   
67    /* (non-Javadoc)
68     * @see de.ugoe.cs.autoquest.plugin.usability2.rules.operator.wrapper.ITaskEntry#getAvailableFilters()
69     */
70    @Override
71    public List<ITaskInstance> getAvailableFilters() {
72        return new ArrayList<ITaskInstance>(instances.keySet());
73    }
74   
75    /*
76     * (non-Javadoc)
77     *
78     * @see java.lang.Object#clone()
79     */
80    @Override
81    public ITask clone() {
82        ITask clone = null;
83        try {
84            clone = (ITask) super.clone();
85        }
86        catch (CloneNotSupportedException e) {
87            // Ignore
88        }
89        return clone;
90    }
91}
Note: See TracBrowser for help on using the repository browser.