Use the NonNull utility methods where we can
[deliverable/tracecompass.git] / org.eclipse.tracecompass.gdbtrace.core / src / org / eclipse / tracecompass / internal / gdbtrace / core / trace / GdbEventAspects.java
1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
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 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.internal.gdbtrace.core.trace;
14
15 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
16
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEvent;
19 import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEventContent;
20 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
21 import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
22 import org.eclipse.tracecompass.tmf.core.event.aspect.TmfEventFieldAspect;
23
24 import com.google.common.collect.ImmutableList;
25
26 /**
27 * Event table column definition for GDB traces.
28 *
29 * @author Alexandre Montplaisir
30 */
31 public final class GdbEventAspects {
32
33 private GdbEventAspects() {}
34
35 private static final @NonNull Iterable<ITmfEventAspect> GDB_ASPECTS =
36 checkNotNull(ImmutableList.of(
37 new GdbTraceFrameAspect(),
38 new GdbTracepointAspect(),
39 new GdbFileAspect()
40 ));
41
42 private static class GdbTraceFrameAspect extends TmfEventFieldAspect {
43 public GdbTraceFrameAspect() {
44 super(GdbTraceEventContent.TRACE_FRAME,
45 GdbTraceEventContent.TRACE_FRAME);
46 }
47 }
48
49 private static class GdbTracepointAspect extends TmfEventFieldAspect {
50 public GdbTracepointAspect() {
51 super(GdbTraceEventContent.TRACEPOINT,
52 GdbTraceEventContent.TRACEPOINT);
53 }
54 }
55
56 private static class GdbFileAspect implements ITmfEventAspect {
57
58 @Override
59 public String getName() {
60 return "File"; //$NON-NLS-1$
61 }
62
63 @Override
64 public String getHelpText() {
65 return EMPTY_STRING;
66 }
67
68 @Override
69 public String resolve(ITmfEvent event) {
70 if (!(event instanceof GdbTraceEvent)) {
71 return EMPTY_STRING;
72 }
73 String ret = ((GdbTraceEvent) event).getReference();
74 return (ret == null ? EMPTY_STRING : ret);
75 }
76
77 @Override
78 public String getFilterId() {
79 return ITmfEvent.EVENT_FIELD_REFERENCE;
80 }
81 }
82
83 /**
84 * Get the event aspects specific to GDB traces.
85 *
86 * @return The set of aspects
87 */
88 public static @NonNull Iterable<ITmfEventAspect> getAspects() {
89 return GDB_ASPECTS;
90 }
91 }
This page took 0.039261 seconds and 5 git commands to generate.