1 /*******************************************************************************
2 * Copyright (c) 2016 École Polytechnique de Montréal
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.tmf
.core
.analysis
.requirements
;
14 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
15 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTraceWithPreDefinedEvents
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfEventTypeCollectionHelper
;
19 * An analysis requirement for event names
21 * @author Geneviève Bastien
24 public class TmfAnalysisEventRequirement
extends TmfAnalysisRequirement
{
27 * Constructor for an optional requirement
29 * TODO: The TYPE_EVENT should be removed and this class used instead
32 * The list of event names the trace must have
34 public TmfAnalysisEventRequirement(Iterable
<String
> eventNames
) {
35 super(TmfAnalysisRequirement
.TYPE_EVENT
, eventNames
, ValuePriorityLevel
.OPTIONAL
);
39 * Constructor. Instantiate a requirement object with a list of values of
43 * The list of event names the trace must have
45 * A level associated with all the values
47 public TmfAnalysisEventRequirement(Iterable
<String
> eventNames
, ValuePriorityLevel level
) {
48 super(TmfAnalysisRequirement
.TYPE_EVENT
, eventNames
, level
);
52 public boolean test(ITmfTrace trace
) {
54 if (trace
instanceof ITmfTraceWithPreDefinedEvents
) {
55 Set
<String
> traceEvents
= TmfEventTypeCollectionHelper
.getEventNames(((ITmfTraceWithPreDefinedEvents
) trace
).getContainedEventTypes());
56 Set
<String
> mandatoryValues
= getValues(ValuePriorityLevel
.MANDATORY
);
57 return traceEvents
.containsAll(mandatoryValues
);