Fix some null warnings
[deliverable/tracecompass.git] / btf / org.eclipse.tracecompass.btf.core / src / org / eclipse / tracecompass / btf / core / trace / BtfEventAspects.java
1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 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 * Matthew Khouzam - Initial API and implementation
11 * Alexandre Montplaisir - Update to new Event Table API
12 * Patrick Tasse - Update for renamed target field
13 *******************************************************************************/
14
15 package org.eclipse.tracecompass.btf.core.trace;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.eclipse.tracecompass.btf.core.event.BtfEvent;
20 import org.eclipse.tracecompass.common.core.NonNullUtils;
21 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
22 import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
23 import org.eclipse.tracecompass.tmf.core.event.aspect.TmfContentFieldAspect;
24
25 import com.google.common.collect.ImmutableList;
26
27 /**
28 * Columns to use in the BTF event table
29 *
30 * @author Alexandre Montplaisir
31 */
32 @NonNullByDefault
33 public final class BtfEventAspects {
34
35 private BtfEventAspects() {}
36
37 private static final Iterable<ITmfEventAspect> BTF_ASPECTS =
38 NonNullUtils.checkNotNull(ImmutableList.of(
39 ITmfEventAspect.BaseAspects.TIMESTAMP,
40 new BtfSourceAspect(),
41 new TmfContentFieldAspect(BtfColumnNames.SOURCE_INSTANCE.toString(), BtfColumnNames.SOURCE_INSTANCE.toString()),
42 ITmfEventAspect.BaseAspects.EVENT_TYPE,
43 new BtfTargetAspect(),
44 new TmfContentFieldAspect(BtfColumnNames.TARGET_INSTANCE.toString(), BtfColumnNames.TARGET_INSTANCE.toString()),
45 new TmfContentFieldAspect(BtfColumnNames.EVENT.toString(), BtfColumnNames.EVENT.toString()),
46 new TmfContentFieldAspect(BtfColumnNames.NOTES.toString(), BtfColumnNames.NOTES.toString())
47 ));
48
49 /**
50 * The "source" aspect, whose value comes from {@link ITmfEvent#getSource()}
51 */
52 private static class BtfSourceAspect implements ITmfEventAspect {
53
54 @Override
55 public String getName() {
56 return BtfColumnNames.SOURCE.toString();
57 }
58
59 @Override
60 public String getHelpText() {
61 return EMPTY_STRING;
62 }
63
64 @Override
65 public @Nullable String resolve(ITmfEvent event) {
66 if (!(event instanceof BtfEvent)) {
67 return EMPTY_STRING;
68 }
69 String ret = ((BtfEvent) event).getSource();
70 return (ret == null ? EMPTY_STRING : ret);
71 }
72 }
73
74 /**
75 * The "target" aspect, taking its value from
76 * {@link ITmfEvent#getTarget()}.
77 */
78 private static class BtfTargetAspect implements ITmfEventAspect {
79
80 @Override
81 public String getName() {
82 return BtfColumnNames.TARGET.toString();
83 }
84
85 @Override
86 public String getHelpText() {
87 return EMPTY_STRING;
88 }
89
90 @Override
91 public @Nullable String resolve(ITmfEvent event) {
92 if (!(event instanceof BtfEvent)) {
93 return EMPTY_STRING;
94 }
95 String ret = ((BtfEvent) event).getTarget();
96 return (ret == null ? EMPTY_STRING : ret);
97 }
98 }
99
100 /**
101 * Return the event aspects defined for BTF traces.
102 *
103 * @return The aspects
104 */
105 public static Iterable<ITmfEventAspect> getAspects() {
106 return BTF_ASPECTS;
107 }
108 }
This page took 0.032608 seconds and 5 git commands to generate.