1 | // Copyright 2015 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.plugin.genericevents.eventCore; |
---|
16 | |
---|
17 | import de.ugoe.cs.autoquest.eventcore.EventTargetModelConfigurationException; |
---|
18 | import de.ugoe.cs.autoquest.eventcore.HierarchicalEventTargetModel; |
---|
19 | import de.ugoe.cs.autoquest.eventcore.IEventTargetFactory; |
---|
20 | import de.ugoe.cs.autoquest.eventcore.IEventTargetSpec; |
---|
21 | import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTarget; |
---|
22 | |
---|
23 | /** |
---|
24 | * <p> |
---|
25 | * TODO comment |
---|
26 | * </p> |
---|
27 | * |
---|
28 | * @author Patrick Harms |
---|
29 | */ |
---|
30 | public class GenericEventTargetFactory implements IEventTargetFactory { |
---|
31 | |
---|
32 | /* (non-Javadoc) |
---|
33 | * @see IEventTargetFactory#instantiateEventTarget(IEventTargetSpec, IHierarchicalEventTarget) |
---|
34 | */ |
---|
35 | @SuppressWarnings("unchecked") |
---|
36 | @Override |
---|
37 | public <T extends IHierarchicalEventTarget> T instantiateEventTarget(IEventTargetSpec specification, |
---|
38 | T parent) |
---|
39 | throws EventTargetModelConfigurationException |
---|
40 | { |
---|
41 | if ((specification instanceof GenericEventTargetSpec) && |
---|
42 | ((parent == null) || (parent instanceof GenericEventTarget))) |
---|
43 | { |
---|
44 | return (T) instantiateEventTarget((GenericEventTargetSpec) specification, |
---|
45 | (GenericEventTarget) parent); |
---|
46 | } |
---|
47 | else { |
---|
48 | throw new IllegalArgumentException |
---|
49 | ("can only handle parameters of type GenericEventTargetSpec and GenericEventTarget"); |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | /* (non-Javadoc) |
---|
54 | * @see IEventTargetFactory#instantiateEventTarget(IEventTargetSpec, IHierarchicalEventTarget) |
---|
55 | */ |
---|
56 | public GenericEventTarget instantiateEventTarget(GenericEventTargetSpec specification, |
---|
57 | GenericEventTarget parent) |
---|
58 | throws EventTargetModelConfigurationException |
---|
59 | { |
---|
60 | return new GenericEventTarget(specification, parent); |
---|
61 | } |
---|
62 | |
---|
63 | /* (non-Javadoc) |
---|
64 | * @see de.ugoe.cs.autoquest.eventcore.IEventTargetFactory#instantiateGroup(java.lang.String, de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTarget, de.ugoe.cs.autoquest.eventcore.HierarchicalEventTargetModel) |
---|
65 | */ |
---|
66 | @Override |
---|
67 | public <T extends IHierarchicalEventTarget> T instantiateGroup(String groupName, |
---|
68 | T parent, |
---|
69 | HierarchicalEventTargetModel<T> hierarchicalEventTargetModel) |
---|
70 | { |
---|
71 | throw new UnsupportedOperationException(); |
---|
72 | } |
---|
73 | |
---|
74 | } |
---|