From: Alexandre Montplaisir Date: Mon, 6 Jul 2015 18:57:27 +0000 (-0400) Subject: tmf: Annotate methods in ITmfEventField X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;ds=sidebyside;h=fafdd006b0a1df7996722bfdf85bb811e8b4b508;p=deliverable%2Ftracecompass.git tmf: Annotate methods in ITmfEventField Some methods in ITmfEventField can be annotated @NonNull to make their usage easier. getValue() and getField() should eventually be marked @Nullable, but this will be a much larger undertaking, as most analysis modules currently just get fields and values without even checking them... Change-Id: I564c6d067a62239cde5c67350ea709315bfe89f4 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/51212 Reviewed-by: Hudson CI Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam Reviewed-by: Patrick Tasse --- diff --git a/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/event/BTFPayload.java b/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/event/BTFPayload.java index 3d62b93064..6c86f19191 100644 --- a/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/event/BTFPayload.java +++ b/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/event/BTFPayload.java @@ -16,6 +16,7 @@ package org.eclipse.tracecompass.btf.core.event; import java.util.Map; import java.util.Map.Entry; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.btf.core.Messages; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; @@ -30,7 +31,7 @@ import com.google.common.collect.ImmutableMap.Builder; public class BTFPayload { /** Description subfield name */ - public static final String DESCRIPTION = "description"; //$NON-NLS-1$ + public static final @NonNull String DESCRIPTION = "description"; //$NON-NLS-1$ private static final Map EVENT_DESCRIPTIONS; private static final String EMPTY = ""; //$NON-NLS-1$ diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfEventFieldTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfEventFieldTest.java index 0a5100bccb..a0f77b70a1 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfEventFieldTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfEventFieldTest.java @@ -60,7 +60,7 @@ public class CtfTmfEventFieldTest { private static final String FLOAT = "float"; private static final String LEN = "len"; private static final String INT = "int"; - private static final String NAME = "test"; + private static final @NonNull String NAME = "test"; private static final String STRUCT = "struct"; private static final String VARIANT = "variant"; private static final String ENUM = "enum"; diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java index 334b7409ef..eee4ad93ef 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java @@ -13,6 +13,8 @@ package org.eclipse.tracecompass.tmf.ctf.core.event; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -258,7 +260,8 @@ public class CtfTmfEvent extends TmfEvent if (structFields != null) { if (structFields.getFieldNames() != null) { for (String curFieldName : structFields.getFieldNames()) { - fields.add(CtfTmfEventField.parseField((IDefinition) structFields.getDefinition(curFieldName), curFieldName)); + String fn = checkNotNull(curFieldName); + fields.add(CtfTmfEventField.parseField((IDefinition) structFields.getDefinition(fn), fn)); } } } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java index ae7fdc30d1..6bc6d92e10 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java @@ -17,11 +17,14 @@ package org.eclipse.tracecompass.tmf.ctf.core.event; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.ctf.core.event.types.AbstractArrayDefinition; import org.eclipse.tracecompass.ctf.core.event.types.CompoundDeclaration; import org.eclipse.tracecompass.ctf.core.event.types.Definition; @@ -62,9 +65,9 @@ public abstract class CtfTmfEventField extends TmfEventField { * @param fields * The children fields. Useful for composite fields */ - protected CtfTmfEventField(String name, Object value, ITmfEventField[] fields) { + protected CtfTmfEventField(@NonNull String name, Object value, ITmfEventField[] fields) { super(/* Strip the underscore from the field name if there is one */ - name.startsWith("_") ? name.substring(1) : name, //$NON-NLS-1$ + name.startsWith("_") ? checkNotNull(name.substring(1)) : name, //$NON-NLS-1$ value, fields); } @@ -85,7 +88,7 @@ public abstract class CtfTmfEventField extends TmfEventField { */ @Deprecated public static CtfTmfEventField parseField(Definition fieldDef, - String fieldName) { + @NonNull String fieldName) { return parseField((IDefinition) fieldDef, fieldName); } @@ -99,7 +102,7 @@ public abstract class CtfTmfEventField extends TmfEventField { * @return The resulting CtfTmfEventField object */ public static CtfTmfEventField parseField(IDefinition fieldDef, - String fieldName) { + @NonNull String fieldName) { CtfTmfEventField field = null; /* Determine the Definition type */ @@ -174,14 +177,15 @@ public abstract class CtfTmfEventField extends TmfEventField { List list = new ArrayList<>(); /* Recursively parse the fields */ for (String curFieldName : strDef.getFieldNames()) { - list.add(CtfTmfEventField.parseField(strDef.getDefinition(curFieldName), curFieldName)); + String fn = checkNotNull(curFieldName); + list.add(CtfTmfEventField.parseField((IDefinition) strDef.getDefinition(fn), fn)); } field = new CTFStructField(fieldName, list.toArray(new CtfTmfEventField[list.size()])); } else if (fieldDef instanceof VariantDefinition) { VariantDefinition varDef = (VariantDefinition) fieldDef; - String curFieldName = varDef.getCurrentFieldName(); + String curFieldName = checkNotNull(varDef.getCurrentFieldName()); IDefinition curFieldDef = varDef.getCurrentField(); if (curFieldDef != null) { CtfTmfEventField subField = CtfTmfEventField.parseField(curFieldDef, curFieldName); @@ -229,7 +233,7 @@ final class CTFIntegerField extends CtfTmfEventField { * @param signed * Is the value signed or not */ - CTFIntegerField(String name, long longValue, int base, boolean signed) { + CTFIntegerField(@NonNull String name, long longValue, int base, boolean signed) { super(name, longValue, null); fSigned = signed; fBase = base; @@ -262,7 +266,7 @@ final class CTFStringField extends CtfTmfEventField { * @param name * The name of this field */ - CTFStringField(String name, String strValue) { + CTFStringField(@NonNull String name, String strValue) { super(name, strValue, null); } @@ -294,7 +298,7 @@ final class CTFIntegerArrayField extends CtfTmfEventField { * @param signed * Are the values in the array signed or not */ - CTFIntegerArrayField(String name, long[] longValues, int base, boolean signed) { + CTFIntegerArrayField(@NonNull String name, long[] longValues, int base, boolean signed) { super(name, longValues, null); fBase = base; fSigned = signed; @@ -336,7 +340,7 @@ final class CTFArrayField extends CtfTmfEventField { * @param elements * The array elements of this field */ - CTFArrayField(String name, CtfTmfEventField[] elements) { + CTFArrayField(@NonNull String name, CtfTmfEventField[] elements) { super(name, elements, elements); } @@ -373,7 +377,7 @@ final class CTFFloatField extends CtfTmfEventField { * @param name * The name of this field */ - protected CTFFloatField(String name, double value) { + protected CTFFloatField(@NonNull String name, double value) { super(name, value, null); } @@ -399,7 +403,7 @@ final class CTFEnumField extends CtfTmfEventField { * @param name * The name of this field */ - CTFEnumField(String name, CtfEnumPair enumValue) { + CTFEnumField(@NonNull String name, CtfEnumPair enumValue) { super(name, new CtfEnumPair(enumValue.getFirst(), enumValue.getSecond()), null); } @@ -425,7 +429,7 @@ final class CTFStructField extends CtfTmfEventField { * @param name * The name of this field */ - CTFStructField(String name, CtfTmfEventField[] fields) { + CTFStructField(@NonNull String name, CtfTmfEventField[] fields) { super(name, fields, fields); } @@ -456,7 +460,7 @@ final class CTFVariantField extends CtfTmfEventField { * @param name * The name of this field */ - CTFVariantField(String name, CtfTmfEventField field) { + CTFVariantField(@NonNull String name, CtfTmfEventField field) { super(name, field, new CtfTmfEventField[] { field }); } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java index f517ff52ba..e91106441d 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java @@ -178,7 +178,7 @@ public class CtfTmfTrace extends TmfTrace List content = new ArrayList<>(); /* Should only return null the first time */ for (String fieldName : ied.getFields().getFieldsList()) { - content.add(new TmfEventField(fieldName, null, null)); + content.add(new TmfEventField(checkNotNull(fieldName), null, null)); } ITmfEventField contentTree = new TmfEventField( ITmfEventField.ROOT_FIELD_ID, diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/util/PcapEventFactory.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/util/PcapEventFactory.java index b50522c680..fd560a7168 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/util/PcapEventFactory.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/util/PcapEventFactory.java @@ -112,7 +112,7 @@ public class PcapEventFactory { while (localPacket != null) { subfieldList.clear(); for (Map.Entry entry : localPacket.getFields().entrySet()) { - String key = entry.getKey(); + String key = checkNotNull(entry.getKey()); String value = entry.getValue(); subfieldList.add(new TmfEventField(key, value, null)); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventFieldTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventFieldTest.java index 3f93214b6e..10a00c8efb 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventFieldTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventFieldTest.java @@ -25,6 +25,7 @@ import static org.junit.Assert.fail; import java.util.Collection; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; @@ -41,8 +42,8 @@ public class TmfEventFieldTest { // Variables // ------------------------------------------------------------------------ - private final String fFieldName1 = "Field-1"; - private final String fFieldName2 = "Field-2"; + private final @NonNull String fFieldName1 = "Field-1"; + private final @NonNull String fFieldName2 = "Field-2"; private final Object fValue1 = "Value"; private final Object fValue2 = Integer.valueOf(10); @@ -51,7 +52,7 @@ public class TmfEventFieldTest { private final TmfEventField fField2 = new TmfEventField(fFieldName2, fValue2, null); private final TmfEventField fField3 = new TmfEventField(fFieldName1, fValue2, null); - private final String fStructRootFieldName = "Root-S"; + private final @NonNull String fStructRootFieldName = "Root-S"; private final String[] fStructFieldNames = new String[] { fFieldName1, fFieldName2 }; private final TmfEventField fStructTerminalField1 = new TmfEventField(fFieldName1, null, null); private final TmfEventField fStructTerminalField2 = new TmfEventField(fFieldName2, null, null); @@ -59,7 +60,7 @@ public class TmfEventFieldTest { private final TmfEventField fStructRootField = new TmfEventField(fStructRootFieldName, null, new ITmfEventField[] { fStructTerminalField1, fStructTerminalField2 }); - private final String fRootFieldName = "Root"; + private final @NonNull String fRootFieldName = "Root"; private final String[] fFieldNames = new String[] { fFieldName1, fFieldName2 }; private final TmfEventField fRootField = new TmfEventField(fRootFieldName, null, new ITmfEventField[] { fField1, fField2 }); @@ -117,15 +118,6 @@ public class TmfEventFieldTest { assertArrayEquals(fFieldNames, names.toArray(new String[names.size()])); } - @Test - public void testConstructorBadArg() { - try { - new TmfEventField(null, fValue1, null); - fail("Invalid (null) field name"); - } catch (final IllegalArgumentException e) { - } - } - @Test public void testTerminalCopyConstructor() { final TmfEventField copy = new TmfEventField(fField1); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java index 07f47b5c31..a1245df779 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java @@ -49,8 +49,8 @@ public class TmfEventTest { private final @NonNull ITmfTrace fTrace = STUB_TRACE.getTrace(); private final String fTypeId = "TestType"; - private final String fLabel1 = "AString"; - private final String fLabel2 = "AnInteger"; + private final @NonNull String fLabel1 = "AString"; + private final @NonNull String fLabel2 = "AnInteger"; private final String[] fLabels = new String[] { fLabel1, fLabel2 }; private final TmfEventType fType = new TmfEventType(fTypeId, TmfEventField.makeRoot(fLabels)); @@ -59,7 +59,7 @@ public class TmfEventTest { private final ITmfEventField fField1a = new TmfEventField(fLabel1, fValue1a, null); private final ITmfEventField fField1b = new TmfEventField(fLabel2, fValue1b, null); private final ITmfEventField[] fFields1 = new ITmfEventField[] { fField1a, fField1b }; - private final String fRawContent1 = fField1a.toString() + fField1b.toString(); + private final @NonNull String fRawContent1 = fField1a.toString() + fField1b.toString(); private final ITmfEventField fContent1 = new TmfEventField(fRawContent1, null, fFields1); private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, 2); private final @NonNull ITmfEvent fEvent1 = new TmfEvent(fTrace, 0, fTimestamp1, fType, fContent1); @@ -69,7 +69,7 @@ public class TmfEventTest { private final ITmfEventField fField2a = new TmfEventField(fLabel1, fValue2a, null); private final ITmfEventField fField2b = new TmfEventField(fLabel2, fValue2b, null); private final ITmfEventField[] fFields2 = new ITmfEventField[] { fField2a, fField2b }; - private final String fRawContent2 = fField2a.toString() + fField2b.toString(); + private final @NonNull String fRawContent2 = fField2a.toString() + fField2b.toString(); private final ITmfEventField fContent2 = new TmfEventField(fRawContent2, null, fFields2); private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, 2); private final @NonNull ITmfEvent fEvent2 = new TmfEvent(fTrace, 1, fTimestamp2, fType, fContent2); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/event/TmfSyncEventStub.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/event/TmfSyncEventStub.java index 5c9c58af54..0137ad106b 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/event/TmfSyncEventStub.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/event/TmfSyncEventStub.java @@ -12,6 +12,7 @@ package org.eclipse.tracecompass.tmf.tests.stubs.event; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.TmfEvent; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; @@ -25,7 +26,7 @@ import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; */ public class TmfSyncEventStub extends TmfEvent { - private static final String stub = "stub"; //$NON-NLS-1$ + private static final @NonNull String stub = "stub"; //$NON-NLS-1$ /** * Constructor diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java index 617985e797..8f635a68d2 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java @@ -13,6 +13,8 @@ package org.eclipse.tracecompass.tmf.tests.stubs.trace.xml; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -272,7 +274,7 @@ public class TmfXmlTraceStub extends TmfTrace { break; } } - fieldsArray[i] = new TmfEventField(fields[i], val, null); + fieldsArray[i] = new TmfEventField(checkNotNull(fields[i]), val, null); } /* Generate the aspects for this trace if it is the aspects special event */ @@ -310,9 +312,6 @@ public class TmfXmlTraceStub extends TmfTrace { /* Add custom aspects in between */ for (ITmfEventField field : fieldsArray) { String name = field.getName(); - if (name == null) { - break; - } final ITmfEventAspect aspect = new TmfContentFieldAspect(name, name); if (name.equals(ASPECT_CPU)) { builder.add(new TmfCpuAspect() { diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventField.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventField.java index 97435a0d71..a6a0571b85 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventField.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventField.java @@ -46,7 +46,7 @@ public interface ITmfEventField { /** * @return the field name */ - String getName(); + @NonNull String getName(); /** * @return the field value @@ -64,7 +64,7 @@ public interface ITmfEventField { * * @return The subfield names (empty Collection if none) */ - Collection getFieldNames(); + @NonNull Collection getFieldNames(); /** * Return the subfields. The iteration order is the same as @@ -72,7 +72,7 @@ public interface ITmfEventField { * * @return The subfields (empty Collection if none) */ - Collection getFields(); + @NonNull Collection getFields(); /** * Return a subfield by its path relative to this field. diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventField.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventField.java index 05dbec9e76..6ae877bbfb 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventField.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventField.java @@ -64,10 +64,7 @@ public class TmfEventField implements ITmfEventField { * @throws IllegalArgumentException * If 'name' is null, or if 'fields' has duplicate field names. */ - public TmfEventField(String name, @Nullable Object value, @Nullable ITmfEventField[] fields) { - if (name == null) { - throw new IllegalArgumentException(); - } + public TmfEventField(@NonNull String name, @Nullable Object value, @Nullable ITmfEventField[] fields) { fName = name; fValue = value; @@ -114,12 +111,12 @@ public class TmfEventField implements ITmfEventField { @Override public Collection getFieldNames() { - return fFields.keySet(); + return checkNotNull(fFields.keySet()); } @Override public Collection getFields() { - return fFields.values(); + return checkNotNull(fFields.values()); } @Override @@ -150,7 +147,8 @@ public class TmfEventField implements ITmfEventField { public static final ITmfEventField makeRoot(final String[] labels) { final ITmfEventField[] fields = new ITmfEventField[labels.length]; for (int i = 0; i < labels.length; i++) { - fields[i] = new TmfEventField(labels[i], null, null); + String label = checkNotNull(labels[i]); + fields[i] = new TmfEventField(label, null, null); } // Return a new root field; return new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null, fields); diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventContent.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventContent.java index 2a86f01004..61e46507d7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventContent.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventContent.java @@ -12,6 +12,7 @@ package org.eclipse.tracecompass.tmf.core.parsers.custom; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; @@ -44,7 +45,7 @@ public class CustomEventContent extends TmfEventField { * @param fields * The array of sub-fields */ - public CustomEventContent(String name, Object content, ITmfEventField[] fields) { + public CustomEventContent(@NonNull String name, Object content, ITmfEventField[] fields) { super(name, content, fields); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventPropertySource.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventPropertySource.java index e4290efdcd..2e88c5a80c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventPropertySource.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventPropertySource.java @@ -127,7 +127,7 @@ public class TmfEventPropertySource implements IPropertySource { @Override public Object getPropertyValue(Object id) { ITmfEventField field = (ITmfEventField) id; - if (field.getFields() != null && field.getFields().size() > 0) { + if (!field.getFields().isEmpty()) { return new ContentPropertySource(field); } return field.getFormattedValue();