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
.jdt
.annotation
.NonNull
;
15 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTraceWithPreDefinedEvents
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfEventTypeCollectionHelper
;
20 * An analysis requirement for event names
22 * @author Geneviève Bastien
25 public class TmfAnalysisEventRequirement
extends TmfAnalysisRequirement
{
28 * Constructor for an optional requirement
30 * TODO: The TYPE_EVENT should be removed and this class used instead
33 * The list of event names the trace must have
35 public TmfAnalysisEventRequirement(Iterable
<String
> eventNames
) {
36 super(TmfAnalysisRequirement
.TYPE_EVENT
, eventNames
, ValuePriorityLevel
.OPTIONAL
);
40 * Constructor. Instantiate a requirement object with a list of values of
44 * The list of event names the trace must have
46 * A level associated with all the values
48 public TmfAnalysisEventRequirement(Iterable
<String
> eventNames
, ValuePriorityLevel level
) {
49 super(TmfAnalysisRequirement
.TYPE_EVENT
, eventNames
, level
);
53 public boolean isFulfilled(@NonNull ITmfTrace trace
) {
55 if (trace
instanceof ITmfTraceWithPreDefinedEvents
) {
56 Set
<String
> traceEvents
= TmfEventTypeCollectionHelper
.getEventNames(((ITmfTraceWithPreDefinedEvents
) trace
).getContainedEventTypes());
57 Set
<String
> mandatoryValues
= getValues(ValuePriorityLevel
.MANDATORY
);
58 return traceEvents
.containsAll(mandatoryValues
);