requirements: make TmfAnalysisRequirement abstract
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core.tests / stubs / org / eclipse / tracecompass / tmf / tests / stubs / analysis / AnalysisModuleTestHelper.java
CommitLineData
b3b03da0 1/*******************************************************************************
60ae41e1 2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
b3b03da0
GB
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial API and implementation
7076c47b 11 * Guilliano Molaire - Implementation of requirements and valid trace types getters
b3b03da0
GB
12 *******************************************************************************/
13
2bdf0193 14package org.eclipse.tracecompass.tmf.tests.stubs.analysis;
b3b03da0 15
63c43609
MR
16import java.util.Collections;
17
b3b03da0 18import org.eclipse.core.runtime.Platform;
54eae41f 19import org.eclipse.jdt.annotation.NonNull;
2bdf0193
AM
20import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
21import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper;
58080002 22import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement;
2bdf0193
AM
23import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
24import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
25import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
26import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub2;
b3b03da0
GB
27import org.osgi.framework.Bundle;
28
7076c47b
GM
29import com.google.common.collect.ImmutableList;
30
b3b03da0
GB
31/**
32 * Analysis Module Helper for the stub analysis source
33 *
34 * @author Geneviève Bastien
35 */
36public class AnalysisModuleTestHelper implements IAnalysisModuleHelper {
37
38 /**
39 * Enum to select an analysis module for this stub
40 */
41 public enum moduleStubEnum {
42 /** Test analysis */
43 TEST,
4d2857be
GB
44 /** Test analysis 2 */
45 TEST2
b3b03da0
GB
46 }
47
48 private moduleStubEnum fModule;
49
50 /**
51 * Constructor
52 *
53 * @param module
54 * The type identifying the module for this helper
55 */
56 public AnalysisModuleTestHelper(moduleStubEnum module) {
57 fModule = module;
58 }
59
60 @Override
61 public String getId() {
ba27dd38 62 return getName();
b3b03da0
GB
63 }
64
65 @Override
66 public String getName() {
0e4f957e 67 return fModule.name();
b3b03da0
GB
68 }
69
70 @Override
71 public boolean isAutomatic() {
72 return false;
73 }
74
ff7b95a5
GB
75 @Override
76 public boolean appliesToExperiment() {
77 return false;
78 }
79
b3b03da0
GB
80 @Override
81 public String getHelpText() {
82 return "";
83 }
84
85 @Override
54eae41f
GB
86 public String getHelpText(@NonNull ITmfTrace trace) {
87 return "";
88 }
89
90 @Override
b3b03da0
GB
91 public String getIcon() {
92 return "";
93 }
94
95 @Override
96 public Bundle getBundle() {
2c7fb5af 97 return Platform.getBundle("org.eclipse.tracecompass.tmf.core.tests");
b3b03da0
GB
98 }
99
100 @Override
101 public boolean appliesToTraceType(Class<? extends ITmfTrace> traceclass) {
102 switch (fModule) {
103 case TEST:
104 return TmfTraceStub.class.isAssignableFrom(traceclass);
4d2857be
GB
105 case TEST2:
106 return TmfTraceStub2.class.isAssignableFrom(traceclass);
b3b03da0
GB
107 default:
108 return false;
109 }
110 }
111
112 @Override
113 public IAnalysisModule newModule(ITmfTrace trace) throws TmfAnalysisException {
114 IAnalysisModule module = null;
115 switch (fModule) {
116 case TEST:
117 module = new TestAnalysis();
118 module.setName(getName());
119 module.setId(getId());
120 module.setAutomatic(isAutomatic());
f479550c
GB
121 if (!module.setTrace(trace)) {
122 module.dispose();
123 module = null;
124 }
b3b03da0 125 break;
4d2857be
GB
126 case TEST2:
127 module = new TestAnalysis2();
b3b03da0
GB
128 module.setName(getName());
129 module.setId(getId());
130 module.setAutomatic(isAutomatic());
f479550c
GB
131 if (!module.setTrace(trace)) {
132 module.dispose();
133 module = null;
134 }
b3b03da0
GB
135 break;
136 default:
137 break;
138
139 }
140 return module;
141 }
142
63c43609
MR
143 @Override
144 public Iterable<Class<? extends ITmfTrace>> getValidTraceTypes() {
7076c47b
GM
145 return ImmutableList.<Class<? extends ITmfTrace>> of(
146 TmfTraceStub.class,
147 TmfTraceStub2.class);
63c43609
MR
148 }
149
150 @Override
58080002 151 public Iterable<TmfAbstractAnalysisRequirement> getAnalysisRequirements() {
7076c47b
GM
152 switch (fModule) {
153 case TEST:
154 return ImmutableList.of(
155 AnalysisRequirementFactory.REQUIREMENT_1,
156 AnalysisRequirementFactory.REQUIREMENT_3);
157 case TEST2:
158 return ImmutableList.of(
159 AnalysisRequirementFactory.REQUIREMENT_2,
160 AnalysisRequirementFactory.REQUIREMENT_3);
161 default:
162 return Collections.EMPTY_SET;
163 }
63c43609 164 }
ff7b95a5 165
b3b03da0 166}
This page took 0.083291 seconds and 5 git commands to generate.