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
;
12 import java
.util
.Collection
;
13 import java
.util
.Collections
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTraceWithPreDefinedEvents
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfEventTypeCollectionHelper
;
21 * An analysis requirement for event names
23 * @author Geneviève Bastien
26 public class TmfAnalysisEventRequirement
extends TmfAnalysisRequirement
{
29 * Constructor for an optional requirement
31 * TODO: The TYPE_EVENT should be removed and this class used instead
34 * The list of event names the trace must have
36 public TmfAnalysisEventRequirement(Collection
<String
> eventNames
) {
37 super(eventNames
, PriorityLevel
.OPTIONAL
);
41 * Constructor. Instantiate a requirement object with a list of values of
45 * The list of event names the trace must have
47 * A level associated with all the values
49 public TmfAnalysisEventRequirement(Collection
<String
> eventNames
, PriorityLevel level
) {
50 super(eventNames
, level
);
54 public boolean test(ITmfTrace trace
) {
56 // TODO: implement for all levels
57 if (trace
instanceof ITmfTraceWithPreDefinedEvents
) {
58 Set
<String
> traceEvents
= TmfEventTypeCollectionHelper
.getEventNames(((ITmfTraceWithPreDefinedEvents
) trace
).getContainedEventTypes());
59 Set
<String
> mandatoryValues
= getPriorityLevel().equals(PriorityLevel
.MANDATORY
) ?
getValues() : Collections
.EMPTY_SET
;
60 return traceEvents
.containsAll(mandatoryValues
);