From df2597e06aa1e8f2a6ea84db36d7e1e51e5f410d Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Fri, 30 Oct 2015 05:47:55 -0400 Subject: [PATCH] Fix some null warnings Change-Id: Ibb291421d2625ab80151e4f193cc09eb8febe747 Signed-off-by: Matthew Khouzam Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/59129 Reviewed-by: Hudson CI --- .../analysis/graph/core/base/TmfGraph.java | 2 +- .../criticalpath/view/CriticalPathView.java | 23 +++++++------ .../ui/views/controlflow/ControlFlowView.java | 6 ---- .../ui/views/resources/ResourcesEntry.java | 8 +++++ .../SystemCallLatencyStatisticsViewer.java | 2 +- ...bstractSegmentStoreScatterGraphViewer.java | 15 ++++---- .../btf/core/trace/BtfEventAspects.java | 12 ++++--- .../tests/types/ArrayDefinition2Test.java | 24 ++++++------- .../ctf/core/trace/CTFStream.java | 11 +++--- .../core/event/types/ArrayDeclaration.java | 2 +- .../ctf/core/trace/iterator/CtfIterator.java | 3 +- .../ctf/core/event/CtfTmfEventFactory.java | 14 ++++---- .../tmf/ctf/core/trace/CtfTmfTrace.java | 11 +++--- .../TraceEventHandlerExecutionGraph.java | 2 +- .../graph/model/LttngSystemModel.java | 4 +-- .../core/analysis/vm/model/VirtualCPU.java | 2 +- .../vm/module/VirtualMachineCpuAnalysis.java | 2 +- .../module/VirtualMachineStateProvider.java | 2 +- .../kernel/core/trace/LttngKernelTrace.java | 11 ++++++ .../debuginfo/UstDebugInfoAnalysisModule.java | 2 +- .../ust/core/trace/LttngUstEventFactory.java | 3 +- .../pcap/core/protocol/ipv4/IPv4Packet.java | 8 +++-- .../pcap/core/protocol/pcap/PcapPacket.java | 5 ++- .../tmf/pcap/core/trace/PcapTrace.java | 21 ++++++------ .../core/treemap/TreeMapStore.java | 8 ++--- .../statesystem/core/AttributeTree.java | 4 +-- .../statesystem/core/StateSystem.java | 9 ++--- .../statesystem/core/TransientState.java | 2 +- .../statesystem/core/ITmfStateSystem.java | 8 ++--- .../core/interval/ITmfStateInterval.java | 3 +- .../xml/ui/views/timegraph/XmlEntry.java | 7 ++++ .../core/tests/event/TmfEventTypeTest.java | 34 ++++++------------- .../core/tests/synchronization/SyncTest.java | 4 ++- .../backends/partial/PartialStateSystem.java | 3 +- .../tmf/core/analysis/TmfAnalysisManager.java | 2 +- .../tmf/core/event/ITmfEventField.java | 2 +- .../tmf/core/event/ITmfEventType.java | 6 ++-- .../tmf/core/event/TmfEventType.java | 14 +++----- .../core/event/matching/TmfEventMatching.java | 10 +++--- .../tmf/core/trace/ITmfTrace.java | 4 +-- .../trace/ITmfTraceWithPreDefinedEvents.java | 2 ++ .../trace/TmfEventTypeCollectionHelper.java | 5 +-- .../tracecompass/tmf/core/trace/TmfTrace.java | 2 +- .../tmf/core/trace/TmfTraceManager.java | 6 ++-- .../tmf/core/trace/TmfTraceUtils.java | 5 +-- .../core/tests/shell/CommandInputTest.java | 7 ++-- .../timegraph/test/stub/model/TraceImpl.java | 11 +++--- .../ui/viewers/tree/ITmfTreeViewerEntry.java | 3 +- .../ui/viewers/tree/TmfTreeViewerEntry.java | 5 ++- .../timechart/TimeChartAnalysisEntry.java | 13 ++++--- .../timegraph/model/EventIterator.java | 10 ++++-- .../timegraph/model/ITimeGraphEntry.java | 24 ++++++++----- .../timegraph/model/TimeGraphEntry.java | 16 ++++----- .../ui/widgets/timegraph/widgets/Utils.java | 4 +-- 54 files changed, 231 insertions(+), 197 deletions(-) diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/base/TmfGraph.java b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/base/TmfGraph.java index 715859b690..561e0c5fd8 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/base/TmfGraph.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core/src/org/eclipse/tracecompass/analysis/graph/core/base/TmfGraph.java @@ -54,7 +54,7 @@ public class TmfGraph { * Constructor */ public TmfGraph() { - fNodeMap = NonNullUtils.checkNotNull(ArrayListMultimap. create()); + fNodeMap = NonNullUtils.checkNotNull(ArrayListMultimap.create()); fReverse = new HashMap<>(); } diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java index e5e5411172..a067abc813 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java @@ -82,9 +82,9 @@ public class CriticalPathView extends AbstractTimeGraphView { COLUMN_PROCESS }; - private final Table> fLinks = NonNullUtils.checkNotNull(HashBasedTable.> create()); + private final Table> fLinks = NonNullUtils.checkNotNull(HashBasedTable.create()); /** The trace to entry list hash map */ - private final Table fObjectStatistics = NonNullUtils.checkNotNull(HashBasedTable. create()); + private final Table fObjectStatistics = NonNullUtils.checkNotNull(HashBasedTable.create()); private final CriticalPathContentProvider fContentProvider = new CriticalPathContentProvider(); @@ -203,7 +203,7 @@ public class CriticalPathView extends AbstractTimeGraphView { private @Nullable Object fCurrentObject; @Override - public @Nullable ITimeGraphEntry[] getElements(@Nullable Object inputElement) { + public ITimeGraphEntry[] getElements(@Nullable Object inputElement) { ITimeGraphEntry[] ret = new ITimeGraphEntry[0]; if (inputElement instanceof List) { List list = (List) inputElement; @@ -225,6 +225,7 @@ public class CriticalPathView extends AbstractTimeGraphView { buildEntryList(worker); entries = workerEntries.get(worker); } + return (entries == null) ? new ITimeGraphEntry[0] : NonNullUtils.checkNotNull(entries.toArray(new ITimeGraphEntry[entries.size()])); @@ -275,10 +276,13 @@ public class CriticalPathView extends AbstractTimeGraphView { } private @Nullable TmfGraph getGraph(final ITmfTrace trace) { - CriticalPathModule module = Iterables.getFirst(TmfTraceUtils.getAnalysisModulesOfClass(trace, CriticalPathModule.class), null); + CriticalPathModule module = Iterables.<@Nullable CriticalPathModule> getFirst( + TmfTraceUtils.getAnalysisModulesOfClass(trace, CriticalPathModule.class), + null); if (module == null) { - return null; + throw new IllegalStateException(); } + module.schedule(); if (!module.waitForCompletion()) { return null; @@ -304,10 +308,12 @@ public class CriticalPathView extends AbstractTimeGraphView { if (trace == null) { return null; } - CriticalPathModule module = Iterables.getFirst(TmfTraceUtils.getAnalysisModulesOfClass(trace, CriticalPathModule.class), null); + CriticalPathModule module = Iterables.<@Nullable CriticalPathModule> getFirst( + TmfTraceUtils.getAnalysisModulesOfClass(trace, CriticalPathModule.class), null); if (module == null) { - return null; + throw new IllegalStateException(); } + final TmfGraph graph = module.getCriticalPath(); if (graph == null) { return null; @@ -475,9 +481,6 @@ public class CriticalPathView extends AbstractTimeGraphView { redraw(); for (ITimeGraphEntry child : entry.getChildren()) { - if (child == null) { - throw new NullPointerException(); - } buildStatusEvents(trace, (CriticalPathEntry) child); } } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/controlflow/ControlFlowView.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/controlflow/ControlFlowView.java index 441756f2a4..38a0b2d1f2 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/controlflow/ControlFlowView.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/controlflow/ControlFlowView.java @@ -501,9 +501,6 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView { if (thread > 0) { break; } - if (trace == null) { - continue; - } ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID); if (ssq == null) { continue; @@ -558,9 +555,6 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView { return list; } for (ITmfTrace trace : TmfTraceManager.getTraceSet(getTrace())) { - if (trace == null) { - continue; - } List currentThreadQuarks = ss.getQuarks(Attributes.CPUS, "*", Attributes.CURRENT_THREAD); //$NON-NLS-1$ for (int currentThreadQuark : currentThreadQuarks) { if (currentThreadQuark >= fullStates.get(0).size()) { diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/resources/ResourcesEntry.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/resources/ResourcesEntry.java index 5a6be09c2c..8e1a128926 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/resources/ResourcesEntry.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/resources/ResourcesEntry.java @@ -13,9 +13,12 @@ package org.eclipse.tracecompass.analysis.os.linux.ui.views.resources; +import java.util.Iterator; + import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.resources.SoftIrqLabelProvider; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; +import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry; @@ -184,4 +187,9 @@ public class ResourcesEntry extends TimeGraphEntry implements Comparable getTimeEventsIterator() { + return super.getTimeEventsIterator(); + } + } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/SystemCallLatencyStatisticsViewer.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/SystemCallLatencyStatisticsViewer.java index 8150672c5b..397c085148 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/SystemCallLatencyStatisticsViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/SystemCallLatencyStatisticsViewer.java @@ -89,7 +89,7 @@ public class SystemCallLatencyStatisticsViewer extends AbstractSegmentStoreStati Iterator> stats = perSyscallStats.entrySet().iterator(); while (stats.hasNext()) { Entry statsEntry = stats.next(); - syscalls.addChild(new SegmentStoreStatisticsEntry(checkNotNull(statsEntry.getKey()), checkNotNull(statsEntry.getValue()))); + syscalls.addChild(new SegmentStoreStatisticsEntry(statsEntry.getKey(), statsEntry.getValue())); } } return root; diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreScatterGraphViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreScatterGraphViewer.java index b56877d2b7..620f44a9af 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreScatterGraphViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreScatterGraphViewer.java @@ -67,7 +67,6 @@ import org.swtchart.Range; * @since 2.0 */ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXLineChartViewer { - private static final List EMPTY_LIST = NonNullUtils.checkNotNull(Collections. emptyList()); private final class CompactingSegmentStoreQuery extends Job { private static final long MAX_POINTS = 1000; @@ -90,14 +89,14 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL final long endTimeInNanos = getTimeInNanos(fCurrentRange.getEndTime()); if (module == null) { setWindowRange(startTimeInNanos, endTimeInNanos); - redraw(statusMonitor, startTimeInNanos, startTimeInNanos, EMPTY_LIST); + redraw(statusMonitor, startTimeInNanos, startTimeInNanos, Collections.EMPTY_LIST); return new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Analysis module not available"); //$NON-NLS-1$ } final ISegmentStore results = module.getResults(); if (results == null) { setWindowRange(startTimeInNanos, endTimeInNanos); - redraw(statusMonitor, startTimeInNanos, startTimeInNanos, EMPTY_LIST); + redraw(statusMonitor, startTimeInNanos, startTimeInNanos, Collections.EMPTY_LIST); return new Status(IStatus.INFO, Activator.PLUGIN_ID, "Analysis module does not have results"); //$NON-NLS-1$ } @@ -142,7 +141,7 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL continue; } if (statusMonitor.isCanceled()) { - return NonNullUtils.checkNotNull(Collections. emptyList()); + return Collections.EMPTY_LIST; } if (!overlaps(last, next)) { displayData.add(next); @@ -156,7 +155,7 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL final List list = new ArrayList<>(); for (ISegment seg : iterable) { if (statusMonitor.isCanceled()) { - return NonNullUtils.checkNotNull(Collections. emptyList()); + return Collections.EMPTY_LIST; } list.add(seg); } @@ -209,7 +208,7 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL /** * Data to display */ - private Collection fDisplayData = NonNullUtils.checkNotNull(Collections. emptyList()); + private Collection fDisplayData = Collections.EMPTY_LIST; /** * Analysis completion listener @@ -283,7 +282,7 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL } }); } - fDisplayData = NonNullUtils.checkNotNull(Collections.EMPTY_LIST); + fDisplayData = Collections.EMPTY_LIST; } else { Collection elements = (Collection) dataInput.getIntersectingElements(currentStart, currentEnd); // getIntersectingElements can return an unsorted iterable, make @@ -411,13 +410,13 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL /** * Returns the segment store analysis module + * * @param trace * The trace to consider * @return the analysis module */ protected @Nullable abstract AbstractSegmentStoreAnalysisModule getSegmentStoreAnalysisModule(ITmfTrace trace); - // ------------------------------------------------------------------------ // Signal handlers // ------------------------------------------------------------------------ diff --git a/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventAspects.java b/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventAspects.java index 873793c253..d09819841e 100644 --- a/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventAspects.java +++ b/btf/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventAspects.java @@ -14,7 +14,8 @@ package org.eclipse.tracecompass.btf.core.trace; -import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.btf.core.event.BtfEvent; import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; @@ -28,11 +29,12 @@ import com.google.common.collect.ImmutableList; * * @author Alexandre Montplaisir */ +@NonNullByDefault public final class BtfEventAspects { private BtfEventAspects() {} - private static final @NonNull Iterable BTF_ASPECTS = + private static final Iterable BTF_ASPECTS = NonNullUtils.checkNotNull(ImmutableList.of( ITmfEventAspect.BaseAspects.TIMESTAMP, new BtfSourceAspect(), @@ -60,7 +62,7 @@ public final class BtfEventAspects { } @Override - public String resolve(ITmfEvent event) { + public @Nullable String resolve(ITmfEvent event) { if (!(event instanceof BtfEvent)) { return EMPTY_STRING; } @@ -86,7 +88,7 @@ public final class BtfEventAspects { } @Override - public String resolve(ITmfEvent event) { + public @Nullable String resolve(ITmfEvent event) { if (!(event instanceof BtfEvent)) { return EMPTY_STRING; } @@ -100,7 +102,7 @@ public final class BtfEventAspects { * * @return The aspects */ - public static @NonNull Iterable getAspects() { + public static Iterable getAspects() { return BTF_ASPECTS; } } \ No newline at end of file diff --git a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/ArrayDefinition2Test.java b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/ArrayDefinition2Test.java index 6f71cb2c8c..df04f5c282 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/ArrayDefinition2Test.java +++ b/ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/ArrayDefinition2Test.java @@ -67,35 +67,34 @@ public class ArrayDefinition2Test { private ArrayDefinition createLongArray() { IntegerDeclaration decl = IntegerDeclaration.createDeclaration(32, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "none", 8); - List defs = createIntDefs(10, 32); + List<@NonNull Definition> defs = createIntDefs(10, 32); ArrayDefinition temp = setUpDeclaration(decl, defs); return temp; } private ArrayDefinition createCharArray() { IntegerDeclaration decl = IntegerDeclaration.createDeclaration(8, false, 10, ByteOrder.BIG_ENDIAN, Encoding.UTF8, "none", 8); - List defs = createIntDefs(4, 8); + List<@NonNull Definition> defs = createIntDefs(4, 8); ArrayDefinition temp = setUpDeclaration(decl, defs); return temp; } private ArrayDefinition createStringArray() { StringDeclaration strDecl = StringDeclaration.getStringDeclaration(Encoding.UTF8); - List defs = createDefs(); + List<@NonNull Definition> defs = createDefs(); ArrayDefinition temp = setUpDeclaration(strDecl, defs); return temp; } private ArrayDefinition setUpDeclaration(@NonNull IDeclaration decl, - @NonNull List defs) { + @NonNull List<@NonNull Definition> defs) { CompoundDeclaration ad = new ArrayDeclaration(0, decl); ArrayDefinition temp = new ArrayDefinition(ad, this.trace, "Testx", defs); return temp; } - @NonNull - private static List createIntDefs(int size, int bits) { - List defs = new ArrayList<>(size); + private static @NonNull List<@NonNull Definition> createIntDefs(int size, int bits) { + List<@NonNull Definition> defs = new ArrayList<>(size); for (int i = 0; i < size; i++) { String content = "test" + i; defs.add(new IntegerDefinition(IntegerDeclaration.createDeclaration(bits, false, @@ -104,10 +103,9 @@ public class ArrayDefinition2Test { return defs; } - @NonNull - private static List createDefs() { + private static @NonNull List<@NonNull Definition> createDefs() { int size = 4; - List defs = new ArrayList<>(); + List<@NonNull Definition> defs = new ArrayList<>(); for (int i = 0; i < size; i++) { String content = "test" + i; defs.add(new StringDefinition( @@ -125,7 +123,7 @@ public class ArrayDefinition2Test { CompoundDeclaration declaration = (CompoundDeclaration) charArrayFixture.getDeclaration(); String fieldName = ""; - ArrayDefinition result = new ArrayDefinition(declaration, this.trace, fieldName, Arrays.asList(new Definition[0])); + ArrayDefinition result = new ArrayDefinition(declaration, this.trace, fieldName, Arrays.asList(new @NonNull Definition[0])); assertNotNull(result); } @@ -140,7 +138,7 @@ public class ArrayDefinition2Test { IDefinitionScope definitionScope = getDefinitionScope(); String fieldName = ""; - ArrayDefinition result = new ArrayDefinition(declaration, definitionScope, fieldName, Arrays.asList(new Definition[0])); + ArrayDefinition result = new ArrayDefinition(declaration, definitionScope, fieldName, Arrays.asList(new @NonNull Definition[0])); assertNotNull(result); } @@ -170,7 +168,7 @@ public class ArrayDefinition2Test { */ @Test public void testgetElem_withDefs() { - List defs = createDefs(); + List<@NonNull Definition> defs = createDefs(); IDefinitionScope definitionScope = getDefinitionScope(); ArrayDefinition ad = new ArrayDefinition((CompoundDeclaration) charArrayFixture.getDeclaration(), definitionScope, "test", defs); int j = 1; diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStream.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStream.java index 5c4b008eb8..b0fb0e54fc 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStream.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStream.java @@ -14,7 +14,6 @@ package org.eclipse.tracecompass.ctf.core.trace; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -226,9 +225,13 @@ public class CTFStream { * * @return The event declarations for this stream */ - public @NonNull Collection getEventDeclarations() { - List retVal = new ArrayList<>(fEvents); - retVal.removeAll(Collections. singletonList(null)); + public @NonNull Collection<@NonNull IEventDeclaration> getEventDeclarations() { + List<@NonNull IEventDeclaration> retVal = new ArrayList<>(); + for (IEventDeclaration eventDeclaration : fEvents) { + if (eventDeclaration != null) { + retVal.add(eventDeclaration); + } + } return retVal; } diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDeclaration.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDeclaration.java index 3983f34804..410012c408 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDeclaration.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDeclaration.java @@ -113,7 +113,7 @@ public final class ArrayDeclaration extends CompoundDeclaration { return new ByteArrayDefinition(this, definitionScope, fieldName, data); } - @NonNull List definitions = read(input, definitionScope, fieldName); + @NonNull List<@NonNull Definition> definitions = read(input, definitionScope, fieldName); return new ArrayDefinition(this, definitionScope, fieldName, definitions); } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/trace/iterator/CtfIterator.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/trace/iterator/CtfIterator.java index d621d5266f..e6c1ae15e9 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/trace/iterator/CtfIterator.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/internal/tmf/ctf/core/trace/iterator/CtfIterator.java @@ -13,6 +13,7 @@ package org.eclipse.tracecompass.internal.tmf.ctf.core.trace.iterator; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; import static org.eclipse.tracecompass.common.core.NonNullUtils.equalsNullable; import org.eclipse.tracecompass.ctf.core.CTFException; @@ -145,7 +146,7 @@ public class CtfIterator extends CTFTraceReader if (top != null) { if (!fCurLocation.equals(fPreviousLocation)) { fPreviousLocation = fCurLocation; - fPreviousEvent = fTrace.getEventFactory().createEvent(fTrace, top.getCurrentEvent(), top.getFilename()); + fPreviousEvent = fTrace.getEventFactory().createEvent(fTrace, checkNotNull(top.getCurrentEvent()), top.getFilename()); } return fPreviousEvent; } diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventFactory.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventFactory.java index 4e8cc08785..0d019fba7a 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventFactory.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventFactory.java @@ -12,7 +12,8 @@ package org.eclipse.tracecompass.tmf.ctf.core.event; -import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.ctf.core.CTFStrings; import org.eclipse.tracecompass.ctf.core.event.EventDefinition; import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration; @@ -31,9 +32,10 @@ import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; * * @author Alexandre Montplaisir */ +@NonNullByDefault public class CtfTmfEventFactory { - private static final @NonNull CtfTmfEventFactory INSTANCE = new CtfTmfEventFactory(); + private static final CtfTmfEventFactory INSTANCE = new CtfTmfEventFactory(); /** * The file name to use when none is specified. @@ -42,7 +44,7 @@ public class CtfTmfEventFactory { * * @since 2.0 */ - protected static final @NonNull String NO_STREAM = "No stream"; //$NON-NLS-1$ + protected static final String NO_STREAM = "No stream"; //$NON-NLS-1$ /** * Protected constructor, only for use by sub-classes. Users should call @@ -58,7 +60,7 @@ public class CtfTmfEventFactory { * @return The instance * @since 2.0 */ - public static @NonNull CtfTmfEventFactory instance() { + public static CtfTmfEventFactory instance() { return INSTANCE; } @@ -74,7 +76,7 @@ public class CtfTmfEventFactory { * @return The newly-built CtfTmfEvent * @since 2.0 */ - public CtfTmfEvent createEvent(CtfTmfTrace trace, EventDefinition eventDef, String fileName) { + public CtfTmfEvent createEvent(CtfTmfTrace trace, EventDefinition eventDef, @Nullable String fileName) { /* Prepare what to pass to CtfTmfEvent's constructor */ final IEventDeclaration eventDecl = eventDef.getDeclaration(); @@ -83,7 +85,7 @@ public class CtfTmfEventFactory { int sourceCPU = eventDef.getCPU(); - String reference = fileName == null ? NO_STREAM : fileName; + String reference = (fileName == null ? NO_STREAM : fileName); /* Handle the special case of lost events */ if (eventDecl.getName().equals(CTFStrings.LOST_EVENT_NAME)) { 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 b3cd9261cc..4bc464bc27 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 @@ -97,7 +97,7 @@ public class CtfTmfTrace extends TmfTrace * Event aspects available for all CTF traces * @since 1.0 */ - protected static final @NonNull Collection CTF_ASPECTS = + protected static final @NonNull Collection<@NonNull ITmfEventAspect> CTF_ASPECTS = checkNotNull(ImmutableList.of( ITmfEventAspect.BaseAspects.TIMESTAMP, new CtfChannelAspect(), @@ -117,11 +117,10 @@ public class CtfTmfTrace extends TmfTrace // Fields // ------------------------------------------- - private final Map fContainedEventTypes = - Collections.synchronizedMap(new HashMap()); + private final Map<@NonNull String, @NonNull CtfTmfEventType> fContainedEventTypes = + Collections.synchronizedMap(new HashMap<>()); - private final CtfIteratorManager fIteratorManager = - new CtfIteratorManager(this); + private final CtfIteratorManager fIteratorManager = new CtfIteratorManager(this); private final @NonNull CtfTmfEventFactory fEventFactory; @@ -481,7 +480,7 @@ public class CtfTmfTrace extends TmfTrace * Gets the list of declared events */ @Override - public Set getContainedEventTypes() { + public Set<@NonNull CtfTmfEventType> getContainedEventTypes() { return ImmutableSet.copyOf(fContainedEventTypes.values()); } diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerExecutionGraph.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerExecutionGraph.java index d7ab07235b..4dcd187944 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerExecutionGraph.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/handlers/TraceEventHandlerExecutionGraph.java @@ -74,7 +74,7 @@ public class TraceEventHandlerExecutionGraph extends BaseHandler { */ public TraceEventHandlerExecutionGraph(LttngKernelExecGraphProvider provider) { super(provider); - fKernel = NonNullUtils.checkNotNull(HashBasedTable. create()); + fKernel = NonNullUtils.checkNotNull(HashBasedTable.create()); fTcpNodes = new HashMap<>(); fMatchProcessing = new IMatchProcessingUnit() { diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/model/LttngSystemModel.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/model/LttngSystemModel.java index d3b264c352..5bb46fe9d6 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/model/LttngSystemModel.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/graph/model/LttngSystemModel.java @@ -34,8 +34,8 @@ import com.google.common.collect.Table; */ public class LttngSystemModel { - private final Table fCurrentTids = NonNullUtils.checkNotNull(HashBasedTable. create()); - private final Table> fIntCtxStacks = NonNullUtils.checkNotNull(HashBasedTable.> create()); + private final Table fCurrentTids = NonNullUtils.checkNotNull(HashBasedTable.create()); + private final Table> fIntCtxStacks = NonNullUtils.checkNotNull(HashBasedTable.create()); private final Map fWorkerMap = new HashMap<>(); /** diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/model/VirtualCPU.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/model/VirtualCPU.java index 66fc0e0f3b..2e2a3be3a6 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/model/VirtualCPU.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/model/VirtualCPU.java @@ -26,7 +26,7 @@ import com.google.common.collect.Table; */ public class VirtualCPU { - private static final Table VIRTUAL_CPU_TABLE = NonNullUtils.checkNotNull(HashBasedTable. create()); + private static final Table VIRTUAL_CPU_TABLE = NonNullUtils.checkNotNull(HashBasedTable.create()); private final VirtualMachine fVm; private final Long fCpuId; diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineCpuAnalysis.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineCpuAnalysis.java index 22b17a7c0d..617ac827f1 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineCpuAnalysis.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineCpuAnalysis.java @@ -58,7 +58,7 @@ import com.google.common.collect.TreeMultimap; public class VirtualMachineCpuAnalysis extends TmfStateSystemAnalysisModule { // TODO: Update with event layout when requirements are back */ - static final Set REQUIRED_EVENTS = NonNullUtils.checkNotNull(ImmutableSet. of( + static final Set REQUIRED_EVENTS = NonNullUtils.checkNotNull(ImmutableSet.of( // LttngStrings.SCHED_SWITCH )); diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java index 08904b328e..f89e267bc7 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/analysis/vm/module/VirtualMachineStateProvider.java @@ -100,7 +100,7 @@ public class VirtualMachineStateProvider extends AbstractTmfStateProvider { super(experiment, "Virtual Machine State Provider"); //$NON-NLS-1$ fModel = new QemuKvmVmModel(experiment); - Table table = NonNullUtils.checkNotNull(HashBasedTable. create()); + Table table = NonNullUtils.checkNotNull(HashBasedTable.create()); fEventNames = table; fLayouts = new HashMap<>(); } diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/lttng2/kernel/core/trace/LttngKernelTrace.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/lttng2/kernel/core/trace/LttngKernelTrace.java index 26c7f94f08..2ec5362895 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/lttng2/kernel/core/trace/LttngKernelTrace.java +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/lttng2/kernel/core/trace/LttngKernelTrace.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.lttng2.kernel.core.trace; import java.util.Collection; import java.util.Map; +import java.util.Set; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -35,6 +36,7 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus; +import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEventType; import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTraceValidationStatus; import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfUtils; @@ -162,4 +164,13 @@ public class LttngKernelTrace extends CtfTmfTrace implements IKernelTrace { return LTTNG_KERNEL_ASPECTS; } + /* + * Needs explicit @NonNull generic type annotation. Can be removed once this + * class becomes @NonNullByDefault. + */ + @Override + public @NonNull Set<@NonNull CtfTmfEventType> getContainedEventTypes() { + return super.getContainedEventTypes(); + } + } diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java index a529aba78d..c6308d13d1 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/debuginfo/UstDebugInfoAnalysisModule.java @@ -76,7 +76,7 @@ public class UstDebugInfoAnalysisModule extends TmfStateSystemAnalysisModule { public Iterable getAnalysisRequirements() { // TODO specify actual requirements once the requirement-checking is // implemented. This analysis needs "ip" and "vpid" contexts. - return checkNotNull(Collections.EMPTY_SET); + return Collections.EMPTY_SET; } @Override diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEventFactory.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEventFactory.java index 9b6dca621a..87e52060af 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEventFactory.java +++ b/lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstEventFactory.java @@ -10,6 +10,7 @@ package org.eclipse.tracecompass.lttng2.ust.core.trace; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.ctf.core.CTFStrings; import org.eclipse.tracecompass.ctf.core.event.EventDefinition; import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration; @@ -42,7 +43,7 @@ public class LttngUstEventFactory extends CtfTmfEventFactory { } @Override - public CtfTmfEvent createEvent(CtfTmfTrace trace, EventDefinition eventDef, String fileName) { + public CtfTmfEvent createEvent(CtfTmfTrace trace, EventDefinition eventDef, @Nullable String fileName) { /* Prepare what to pass to CtfTmfEvent's constructor */ final IEventDeclaration eventDecl = eventDef.getDeclaration(); final long ts = eventDef.getTimestamp(); diff --git a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ipv4/IPv4Packet.java b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ipv4/IPv4Packet.java index 44d9e66277..5574fddab3 100644 --- a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ipv4/IPv4Packet.java +++ b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ipv4/IPv4Packet.java @@ -13,6 +13,7 @@ package org.eclipse.tracecompass.internal.pcap.core.protocol.ipv4; import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; +import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString; import java.net.Inet4Address; import java.net.InetAddress; @@ -22,6 +23,7 @@ import java.nio.ByteOrder; import java.util.Arrays; import java.util.Map; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.internal.pcap.core.packet.BadPacketException; @@ -435,7 +437,7 @@ public class IPv4Packet extends Packet { public Map getFields() { Map map = fFields; if (map == null) { - Builder builder = ImmutableMap. builder() + Builder<@NonNull String, @NonNull String> builder = ImmutableMap.<@NonNull String, @NonNull String> builder() .put("Version", String.valueOf(fVersion)) //$NON-NLS-1$ .put("Header Length", String.valueOf(getHeaderLength()) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$ .put("Differentiated Services Field", String.format("%s%02x", "0x", fDSCP)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -448,8 +450,8 @@ public class IPv4Packet extends Packet { .put("Time to live", String.valueOf(fTimeToLive)) //$NON-NLS-1$ .put("Protocol", IPProtocolNumberHelper.toString(fIpDatagramProtocol) + " (" + String.valueOf(fIpDatagramProtocol) + ")") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ .put("Checksum", String.format("%s%04x", "0x", fHeaderChecksum)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - .put("Source IP Address", fSourceIpAddress.getHostAddress()) //$NON-NLS-1$ - .put("Destination IP Address", fDestinationIpAddress.getHostAddress()); //$NON-NLS-1$ + .put("Source IP Address", nullToEmptyString(fSourceIpAddress.getHostAddress())) //$NON-NLS-1$ + .put("Destination IP Address", nullToEmptyString(fDestinationIpAddress.getHostAddress())); //$NON-NLS-1$ byte[] options = fOptions; if (options == null) { builder.put("Options", EMPTY_STRING); //$NON-NLS-1$ diff --git a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/pcap/PcapPacket.java b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/pcap/PcapPacket.java index be6ae08961..cd0ad45cfe 100644 --- a/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/pcap/PcapPacket.java +++ b/pcap/org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/pcap/PcapPacket.java @@ -236,7 +236,7 @@ public class PcapPacket extends Packet { @Override public PcapEndpoint getSourceEndpoint() { - @Nullable PcapEndpoint endpoint = fSourceEndpoint; + PcapEndpoint endpoint = fSourceEndpoint; if (endpoint == null) { endpoint = new PcapEndpoint(this, true); } @@ -246,7 +246,6 @@ public class PcapPacket extends Packet { @Override public PcapEndpoint getDestinationEndpoint() { - @Nullable PcapEndpoint endpoint = fDestinationEndpoint; if (endpoint == null) { @@ -262,7 +261,7 @@ public class PcapPacket extends Packet { public Map getFields() { Map map = fFields; if (map == null) { - ImmutableMap.Builder builder = ImmutableMap. builder(); + ImmutableMap.Builder builder = ImmutableMap.builder(); builder.put("Frame", String.valueOf(fPacketIndex)); //$NON-NLS-1$ builder.put("Frame Length", String.valueOf(fOriginalLength) + " bytes"); //$NON-NLS-1$ //$NON-NLS-2$ builder.put("Capture Length", String.valueOf(fIncludedLength) + " bytes"); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/trace/PcapTrace.java b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/trace/PcapTrace.java index 2f5b911311..273e788deb 100644 --- a/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/trace/PcapTrace.java +++ b/pcap/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/trace/PcapTrace.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.internal.tmf.pcap.core.trace; import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; +import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString; import java.io.IOException; import java.nio.channels.ClosedChannelException; @@ -28,9 +29,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.internal.pcap.core.packet.BadPacketException; import org.eclipse.tracecompass.internal.pcap.core.protocol.pcap.PcapPacket; import org.eclipse.tracecompass.internal.pcap.core.trace.BadPcapFileException; @@ -70,7 +69,7 @@ public class PcapTrace extends TmfTrace implements ITmfTraceProperties { /** pcap trace type id as defined in plugin.xml */ public static final String TRACE_TYPE_ID = "org.eclipse.linuxtools.tmf.pcap.core.pcaptrace"; //$NON-NLS-1$ - private @NonNull static final Collection PCAP_ASPECTS = + private static final Collection PCAP_ASPECTS = checkNotNull(ImmutableList.of( ITmfEventAspect.BaseAspects.TIMESTAMP, PcapSourceAspect.INSTANCE, @@ -80,7 +79,7 @@ public class PcapTrace extends TmfTrace implements ITmfTraceProperties { ITmfEventAspect.BaseAspects.CONTENTS )); - private @NonNull static final String EMPTY_STRING = ""; //$NON-NLS-1$ + private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private static final int CONFIDENCE = 50; private @Nullable PcapFile fPcapFile; private @Nullable Map fTraceProperties = null; @@ -248,18 +247,18 @@ public class PcapTrace extends TmfTrace implements ITmfTraceProperties { public synchronized Map getTraceProperties() { PcapFile pcap = fPcapFile; if (pcap == null) { - return checkNotNull(Collections. emptyMap()); + return Collections.emptyMap(); } Map properties = fTraceProperties; if (properties == null) { ImmutableMap.Builder builder = ImmutableMap.builder(); - builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_Version), String.format("%d%c%d", pcap.getMajorVersion(), '.', pcap.getMinorVersion())); //$NON-NLS-1$ - builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_TimeZoneCorrection), pcap.getTimeZoneCorrection() + " s"); //$NON-NLS-1$ - builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_TimestampAccuracy), String.valueOf(pcap.getTimeAccuracy())); - builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_MaxSnapLength), pcap.getSnapLength() + " bytes"); //$NON-NLS-1$ - builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_LinkLayerHeaderType), LinkTypeHelper.toString((int) pcap.getDataLinkType()) + " (" + pcap.getDataLinkType() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - builder.put(NonNullUtils.nullToEmptyString(Messages.PcapTrace_FileEndianness), pcap.getByteOrder().toString()); + builder.put(nullToEmptyString(Messages.PcapTrace_Version), String.format("%d%c%d", pcap.getMajorVersion(), '.', pcap.getMinorVersion())); //$NON-NLS-1$ + builder.put(nullToEmptyString(Messages.PcapTrace_TimeZoneCorrection), pcap.getTimeZoneCorrection() + " s"); //$NON-NLS-1$ + builder.put(nullToEmptyString(Messages.PcapTrace_TimestampAccuracy), String.valueOf(pcap.getTimeAccuracy())); + builder.put(nullToEmptyString(Messages.PcapTrace_MaxSnapLength), pcap.getSnapLength() + " bytes"); //$NON-NLS-1$ + builder.put(nullToEmptyString(Messages.PcapTrace_LinkLayerHeaderType), LinkTypeHelper.toString((int) pcap.getDataLinkType()) + " (" + pcap.getDataLinkType() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + builder.put(nullToEmptyString(Messages.PcapTrace_FileEndianness), nullToEmptyString(pcap.getByteOrder().toString())); return checkNotNull(builder.build()); diff --git a/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java b/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java index 01ce5017c8..0bca75b6f7 100644 --- a/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java +++ b/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java @@ -79,11 +79,11 @@ public class TreeMapStore implements ISegmentStore { * The same is done for the end times index, but swapping the first two * comparators instead. */ - fStartTimesIndex = checkNotNull(TreeMultimap. create( + fStartTimesIndex = checkNotNull(TreeMultimap.create( SegmentComparators.LONG_COMPARATOR, Ordering.from(SegmentComparators.INTERVAL_END_COMPARATOR).compound(Ordering.natural()))); - fEndTimesIndex = checkNotNull(TreeMultimap. create( + fEndTimesIndex = checkNotNull(TreeMultimap.create( SegmentComparators.LONG_COMPARATOR, Ordering.from(SegmentComparators.INTERVAL_START_COMPARATOR).compound(Ordering.natural()))); @@ -164,7 +164,7 @@ public class TreeMapStore implements ISegmentStore { public Object[] toArray() { fLock.readLock().lock(); try { - return checkNotNull(fStartTimesIndex.values().toArray()); + return fStartTimesIndex.values().toArray(); } finally { fLock.readLock().unlock(); } @@ -174,7 +174,7 @@ public class TreeMapStore implements ISegmentStore { public T[] toArray(T @Nullable[] a) { fLock.readLock().lock(); try { - return checkNotNull(fStartTimesIndex.values().toArray(a)); + return fStartTimesIndex.values().toArray(a); } finally { fLock.readLock().unlock(); } diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java index 97f8777de4..54ea463e83 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/AttributeTree.java @@ -258,9 +258,9 @@ public final class AttributeTree { * If 'attributeQuark' is invalid, or if there is no attrbiute * associated to it. */ - public synchronized @NonNull List getSubAttributes(int attributeQuark, boolean recursive) + public synchronized @NonNull List<@NonNull Integer> getSubAttributes(int attributeQuark, boolean recursive) throws AttributeNotFoundException { - List listOfChildren = new ArrayList<>(); + List<@NonNull Integer> listOfChildren = new ArrayList<>(); Attribute startingAttribute; /* Check if the quark is valid */ diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java index 09ce7cbef3..d4c85ff77c 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java @@ -25,6 +25,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend; import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; @@ -279,8 +280,8 @@ public class StateSystem implements ITmfStateSystemBuilder { } @Override - public List getQuarks(String... pattern) { - List quarks = new LinkedList<>(); + public List<@NonNull Integer> getQuarks(String... pattern) { + List<@NonNull Integer> quarks = new LinkedList<>(); List prefix = new LinkedList<>(); List suffix = new LinkedList<>(); boolean split = false; @@ -544,7 +545,7 @@ public class StateSystem implements ITmfStateSystemBuilder { * @param newStateIntervals * The new List of state values to use as ongoing state info */ - protected void replaceOngoingState(@NonNull List newStateIntervals) { + protected void replaceOngoingState(@NonNull List<@NonNull ITmfStateInterval> newStateIntervals) { transState.replaceOngoingState(newStateIntervals); } @@ -560,7 +561,7 @@ public class StateSystem implements ITmfStateSystemBuilder { } final int nbAttr = getNbAttributes(); - List stateInfo = new ArrayList<>(nbAttr); + List<@Nullable ITmfStateInterval> stateInfo = new ArrayList<>(nbAttr); /* Bring the size of the array to the current number of attributes */ for (int i = 0; i < nbAttr; i++) { diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java index b7c4fc81f4..dfa22f0ebc 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/TransientState.java @@ -343,7 +343,7 @@ public class TransientState { * @param t * The requested timestamp */ - public void doQuery(List stateInfo, long t) { + public void doQuery(List<@Nullable ITmfStateInterval> stateInfo, long t) { fRWLock.readLock().lock(); try { if (!this.fIsActive) { diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java index 3f63cb6955..3236bfc4a8 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/ITmfStateSystem.java @@ -172,7 +172,7 @@ public interface ITmfStateSystem { * @throws AttributeNotFoundException * If the quark was not existing or invalid. */ - @NonNull List getSubAttributes(int quark, boolean recursive) + @NonNull List<@NonNull Integer> getSubAttributes(int quark, boolean recursive) throws AttributeNotFoundException; /** @@ -195,7 +195,7 @@ public interface ITmfStateSystem { * @throws AttributeNotFoundException * If the 'quark' was not existing or invalid. */ - List getSubAttributes(int quark, boolean recursive, String pattern) + @NonNull List<@NonNull Integer> getSubAttributes(int quark, boolean recursive, String pattern) throws AttributeNotFoundException; /** @@ -222,7 +222,7 @@ public interface ITmfStateSystem { * the pattern. If no attribute matched, the list will be empty (but * not null). */ - List getQuarks(String... pattern); + @NonNull List<@NonNull Integer> getQuarks(String... pattern); /** * Return the name assigned to this quark. This returns only the "basename", @@ -327,7 +327,7 @@ public interface ITmfStateSystem { * @throws StateSystemDisposedException * If the query is sent after the state system has been disposed */ - @NonNull List queryFullState(long t) + @NonNull List<@NonNull ITmfStateInterval> queryFullState(long t) throws StateSystemDisposedException; /** diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/interval/ITmfStateInterval.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/interval/ITmfStateInterval.java index b3279219fd..93b019486b 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/interval/ITmfStateInterval.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/statesystem/core/interval/ITmfStateInterval.java @@ -12,6 +12,7 @@ package org.eclipse.tracecompass.statesystem.core.interval; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; /** @@ -51,7 +52,7 @@ public interface ITmfStateInterval { * * @return the state value represented by this interval */ - ITmfStateValue getStateValue(); + @NonNull ITmfStateValue getStateValue(); /** * Test if this interval intersects another timestamp, inclusively. diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java index 7b9901dba4..0b3550fbd5 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java @@ -14,6 +14,7 @@ package org.eclipse.tracecompass.tmf.analysis.xml.ui.views.timegraph; import java.util.Collections; +import java.util.Iterator; import java.util.List; import org.eclipse.jdt.annotation.NonNull; @@ -28,6 +29,7 @@ import org.eclipse.tracecompass.tmf.analysis.xml.core.model.readonly.TmfXmlReadO import org.eclipse.tracecompass.tmf.analysis.xml.core.module.IXmlStateSystemContainer; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlUtils; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; +import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry; import org.w3c.dom.Element; @@ -265,4 +267,9 @@ public class XmlEntry extends TimeGraphEntry implements IXmlStateSystemContainer return Collections.EMPTY_SET; } + @Override + public Iterator<@NonNull ITimeEvent> getTimeEventsIterator() { + return super.getTimeEventsIterator(); + } + } diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeTest.java index 967a14477b..341c3aaa5a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeTest.java @@ -19,10 +19,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.util.Collection; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.ITmfEventType; import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; @@ -38,21 +38,21 @@ public class TmfEventTypeTest { // Variables // ------------------------------------------------------------------------ - private final String fTypeId1 = "Some type"; - private final String fTypeId2 = "Some other type"; + private final @NonNull String fTypeId1 = "Some type"; + private final @NonNull String fTypeId2 = "Some other type"; - private final String fLabel0 = "label1"; - private final String fLabel1 = "label2"; - private final String fLabel2 = "label3"; + private final @NonNull String fLabel0 = "label1"; + private final @NonNull String fLabel1 = "label2"; + private final @NonNull String fLabel2 = "label3"; private final String[] fLabels0 = new String[] { }; private final String[] fLabels1 = new String[] { fLabel0, fLabel1 }; private final String[] fLabels2 = new String[] { fLabel1, fLabel0, fLabel2 }; - private final ITmfEventType fType0 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels0)); - private final ITmfEventType fType1 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels1)); - private final ITmfEventType fType2 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels2)); - private final ITmfEventType fType3 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels1)); + private final @NonNull ITmfEventType fType0 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels0)); + private final @NonNull ITmfEventType fType1 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels1)); + private final @NonNull ITmfEventType fType2 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels2)); + private final @NonNull ITmfEventType fType3 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels1)); // ------------------------------------------------------------------------ // Constructors @@ -90,11 +90,6 @@ public class TmfEventTypeTest { assertArrayEquals(fLabels2, labels2.toArray(new String[labels2.size()])); } - @Test(expected = IllegalArgumentException.class) - public void testConstructorCornerCases() { - new TmfEventType(null, null); - } - @Test public void testCopyConstructor() { final TmfEventType original = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels1)); @@ -107,15 +102,6 @@ public class TmfEventTypeTest { assertArrayEquals(fLabels1, labels1.toArray(new String[labels1.size()])); } - @Test - public void testCopyConstructorCornerCases() { - try { - new TmfEventType(null); - fail("TmfEventType: null argument"); - } catch (final IllegalArgumentException e) { - } - } - // ------------------------------------------------------------------------ // hashCode // ------------------------------------------------------------------------ diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/SyncTest.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/SyncTest.java index 15e81e6cbe..ac38003992 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/SyncTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/synchronization/SyncTest.java @@ -24,8 +24,10 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.core.synchronization.SyncAlgorithmFullyIncremental; import org.eclipse.tracecompass.tmf.core.event.matching.TmfEventDependency; import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform; @@ -49,7 +51,7 @@ import org.junit.Test; public class SyncTest { private TmfTraceStub t1, t2; - private Collection fTraces; + private @NonNull Collection fTraces = Collections.EMPTY_LIST; /** * Initializing the traces diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialStateSystem.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialStateSystem.java index 45a8308cca..a94670ce30 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialStateSystem.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/statesystem/backends/partial/PartialStateSystem.java @@ -16,6 +16,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.statesystem.core.AttributeTree; import org.eclipse.tracecompass.internal.statesystem.core.StateSystem; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; @@ -77,7 +78,7 @@ public class PartialStateSystem extends StateSystem { // ------------------------------------------------------------------------ @Override - public void replaceOngoingState(List ongoingIntervals) { + public void replaceOngoingState(List<@NonNull ITmfStateInterval> ongoingIntervals) { super.replaceOngoingState(ongoingIntervals); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisManager.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisManager.java index 6899bef895..5fbd9fd0d7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisManager.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisManager.java @@ -42,7 +42,7 @@ import com.google.common.collect.Multimap; @NonNullByDefault public class TmfAnalysisManager { - private static final Multimap fAnalysisModules = NonNullUtils.checkNotNull(HashMultimap. create()); + private static final Multimap fAnalysisModules = NonNullUtils.checkNotNull(HashMultimap.create()); private static final Map>> fParameterProviders = new HashMap<>(); private static final Map, IAnalysisParameterProvider> fParamProviderInstances = new HashMap<>(); private static final List fSources = new ArrayList<>(); 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 a9b7d22050..b8046f48af 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 @@ -64,7 +64,7 @@ public interface ITmfEventField { * * @return The subfield names (empty Collection if none) */ - @NonNull Collection getFieldNames(); + @NonNull Collection<@NonNull String> getFieldNames(); /** * Return the subfields. The iteration order is the same as diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventType.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventType.java index f4096c9294..3292302c03 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventType.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventType.java @@ -14,6 +14,8 @@ package org.eclipse.tracecompass.tmf.core.event; import java.util.Collection; +import org.eclipse.jdt.annotation.NonNull; + /** * The generic event type in TMF. It contains a reference to the full field structure * for that event type. @@ -35,7 +37,7 @@ public interface ITmfEventType { /** * The default event type name */ - String DEFAULT_TYPE_ID = "TmfType"; //$NON-NLS-1$ + @NonNull String DEFAULT_TYPE_ID = "TmfType"; //$NON-NLS-1$ // ------------------------------------------------------------------------ // Getters @@ -44,7 +46,7 @@ public interface ITmfEventType { /** * @return the event type ID */ - String getName(); + @NonNull String getName(); /** * @return the event type root field diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventType.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventType.java index 08a4e22f72..428fc1c4f7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventType.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventType.java @@ -16,6 +16,8 @@ package org.eclipse.tracecompass.tmf.core.event; import java.util.Collection; import java.util.Collections; +import org.eclipse.jdt.annotation.NonNull; + /** * A basic implementation of ITmfEventType. * @@ -31,7 +33,7 @@ public class TmfEventType implements ITmfEventType { // Attributes // ------------------------------------------------------------------------ - private final String fTypeId; + private final @NonNull String fTypeId; private final ITmfEventField fRootField; // ------------------------------------------------------------------------ @@ -51,10 +53,7 @@ public class TmfEventType implements ITmfEventType { * @param typeId the type name * @param root the root field */ - public TmfEventType(final String typeId, final ITmfEventField root) { - if (typeId == null) { - throw new IllegalArgumentException(); - } + public TmfEventType(final @NonNull String typeId, final ITmfEventField root) { fTypeId = typeId; fRootField = root; } @@ -64,10 +63,7 @@ public class TmfEventType implements ITmfEventType { * * @param type the other type */ - public TmfEventType(final ITmfEventType type) { - if (type == null) { - throw new IllegalArgumentException(); - } + public TmfEventType(@NonNull ITmfEventType type) { fTypeId = type.getName(); fRootField = type.getRootField(); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/TmfEventMatching.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/TmfEventMatching.java index 119c8f225c..b6366e5eb8 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/TmfEventMatching.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/TmfEventMatching.java @@ -12,6 +12,8 @@ package org.eclipse.tracecompass.tmf.core.event.matching; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -50,7 +52,7 @@ public class TmfEventMatching implements ITmfEventMatching { /** * The array of traces to match */ - private final Collection fTraces; + private final @NonNull Collection<@NonNull ITmfTrace> fTraces; /** * The class to call once a match is found @@ -91,7 +93,7 @@ public class TmfEventMatching implements ITmfEventMatching { * The set of traces for which to match events * @since 1.0 */ - public TmfEventMatching(Collection traces) { + public TmfEventMatching(Collection<@NonNull ITmfTrace> traces) { this(traces, new TmfEventMatches()); } @@ -103,7 +105,7 @@ public class TmfEventMatching implements ITmfEventMatching { * @param tmfEventMatches * The match processing class */ - public TmfEventMatching(Collection traces, IMatchProcessingUnit tmfEventMatches) { + public TmfEventMatching(Collection<@NonNull ITmfTrace> traces, IMatchProcessingUnit tmfEventMatches) { if (tmfEventMatches == null) { throw new IllegalArgumentException(); } @@ -287,7 +289,7 @@ public class TmfEventMatching implements ITmfEventMatching { * lists */ if (found) { - getProcessingUnit().addMatch(dep); + getProcessingUnit().addMatch(checkNotNull(dep)); monitor.subTask(NLS.bind(Messages.TmfEventMatching_MatchesFound, getProcessingUnit().countMatches())); } else { /* diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTrace.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTrace.java index 56b7ba45a7..01e326072c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTrace.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTrace.java @@ -253,7 +253,7 @@ public interface ITmfTrace extends ITmfEventProvider { * * @return An iterable view of the analysis modules */ - @NonNull Iterable getAnalysisModules(); + @NonNull Iterable<@NonNull IAnalysisModule> getAnalysisModules(); // ------------------------------------------------------------------------ // Aspect getters @@ -267,7 +267,7 @@ public interface ITmfTrace extends ITmfEventProvider { * * @return The event aspects for this trace */ - @NonNull Iterable getEventAspects(); + @NonNull Iterable<@NonNull ITmfEventAspect> getEventAspects(); // ------------------------------------------------------------------------ // Trace characteristics getters diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceWithPreDefinedEvents.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceWithPreDefinedEvents.java index b57ac4045e..13cb6510c2 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceWithPreDefinedEvents.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceWithPreDefinedEvents.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.core.trace; import java.util.Set; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.tracecompass.tmf.core.event.ITmfEventType; /** @@ -31,6 +32,7 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEventType; * @author Geneviève Bastien * @author Matthew Khouzam */ +@NonNullByDefault public interface ITmfTraceWithPreDefinedEvents { /** diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfEventTypeCollectionHelper.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfEventTypeCollectionHelper.java index 7adfc0c0ff..029151210d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfEventTypeCollectionHelper.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfEventTypeCollectionHelper.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.core.trace; import java.util.HashSet; import java.util.Set; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.event.ITmfEventType; /** @@ -37,8 +38,8 @@ public final class TmfEventTypeCollectionHelper { * @return a set of the names of these events, if some names are clashing * they will only appear once */ - public static Set getEventNames(Iterable eventTypes) { - Set retSet = new HashSet<>(); + public static Set<@NonNull String> getEventNames(Iterable<@NonNull ? extends ITmfEventType> eventTypes) { + Set<@NonNull String> retSet = new HashSet<>(); for (ITmfEventType eventType : eventTypes) { retSet.add(eventType.getName()); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java index 5295364f9d..7876c3315f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java @@ -100,7 +100,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT /** * Basic aspects that should be valid for all trace types. */ - public static final @NonNull Collection BASE_ASPECTS = + public static final @NonNull Collection<@NonNull ITmfEventAspect> BASE_ASPECTS = checkNotNull(ImmutableList.of( ITmfEventAspect.BaseAspects.TIMESTAMP, ITmfEventAspect.BaseAspects.EVENT_TYPE, diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java index 71bd80d38b..77a43cb043 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java @@ -177,11 +177,11 @@ public final class TmfTraceManager { * The trace or experiment * @return The corresponding trace set. */ - public static @NonNull Collection getTraceSet(ITmfTrace trace) { + public static @NonNull Collection<@NonNull ITmfTrace> getTraceSet(ITmfTrace trace) { if (trace == null) { - return NonNullUtils.checkNotNull(ImmutableSet. of()); + return NonNullUtils.checkNotNull(ImmutableSet.of()); } - List traces = trace.getChildren(ITmfTrace.class); + List<@NonNull ITmfTrace> traces = trace.getChildren(ITmfTrace.class); if (traces.size() > 0) { return NonNullUtils.checkNotNull(ImmutableSet.copyOf(traces)); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java index fc8baad479..aa2c038994 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; @@ -72,9 +73,9 @@ public final class TmfTraceUtils { * Returned modules must extend this class * @return List of modules of class moduleClass */ - public static Iterable getAnalysisModulesOfClass(ITmfTrace trace, Class moduleClass) { + public static Iterable<@NonNull T> getAnalysisModulesOfClass(ITmfTrace trace, Class moduleClass) { Iterable analysisModules = trace.getAnalysisModules(); - Set modules = new HashSet<>(); + Set<@NonNull T> modules = new HashSet<>(); for (IAnalysisModule module : analysisModules) { if (moduleClass.isAssignableFrom(module.getClass())) { modules.add(moduleClass.cast(module)); diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandInputTest.java b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandInputTest.java index c3c8d98530..7235a8adc5 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandInputTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandInputTest.java @@ -19,7 +19,6 @@ import java.util.Arrays; import java.util.List; import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandInput; import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput; import org.junit.Test; @@ -30,7 +29,7 @@ import org.junit.Test; public class CommandInputTest { private static final @NonNull String COMMAND = "my-command"; - private static final String @NonNull [] CMD_INPUT = { "This", "are", "the", "params" }; + private static final @NonNull String @NonNull [] CMD_INPUT = { "This", "are", "the", "params" }; /** * Test suite for the {@link CommandInput#add(String)} and {@link CommandInput#addAll(List)} @@ -39,8 +38,8 @@ public class CommandInputTest { public void testConstructorAndAdd() { ICommandInput iunput = new CommandInput(); iunput.add(COMMAND); - List params = Arrays.asList(CMD_INPUT); - iunput.addAll(NonNullUtils.checkNotNull(params)); + @NonNull List<@NonNull String> params = Arrays.asList(CMD_INPUT); + iunput.addAll(params); List expectedList = new ArrayList<>(); expectedList.add(COMMAND); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/test/stub/model/TraceImpl.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/test/stub/model/TraceImpl.java index 0cf9974014..89ee9a86e8 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/test/stub/model/TraceImpl.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/test/stub/model/TraceImpl.java @@ -15,6 +15,7 @@ import java.util.Iterator; import java.util.List; import java.util.Vector; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry; @@ -29,7 +30,7 @@ public class TraceImpl implements ITimeGraphEntry { private long startTime = 0; private long stopTime = 1; private String className = "defaultClassName"; - private Vector traceEvents = new Vector<>(); + private Vector<@NonNull ITimeEvent> traceEvents = new Vector<>(); // ======================================================================== // Constructor @@ -87,21 +88,21 @@ public class TraceImpl implements ITimeGraphEntry { } @Override - public Iterator getTimeEventsIterator() { + public Iterator<@NonNull ITimeEvent> getTimeEventsIterator() { return traceEvents.iterator(); } @Override - public Iterator getTimeEventsIterator(long aStartTime, long aStopTime, long maxDuration) { + public Iterator<@NonNull ITimeEvent> getTimeEventsIterator(long aStartTime, long aStopTime, long maxDuration) { return traceEvents.iterator(); } - public void addTraceEvent(ITimeEvent event) { + public void addTraceEvent(@NonNull ITimeEvent event) { traceEvents.add(event); } @Override - public List getChildren() { + public List<@NonNull ITimeGraphEntry> getChildren() { return null; } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/ITmfTreeViewerEntry.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/ITmfTreeViewerEntry.java index 2c2a11b6a6..2a114fafdf 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/ITmfTreeViewerEntry.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/ITmfTreeViewerEntry.java @@ -43,8 +43,7 @@ public interface ITmfTreeViewerEntry { * * @return an array of child elements */ - @NonNull - List getChildren(); + @NonNull List<@NonNull ? extends ITmfTreeViewerEntry> getChildren(); /** * Returns the name of this entry. diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/TmfTreeViewerEntry.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/TmfTreeViewerEntry.java index ff4ce3a49d..65cb795a2c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/TmfTreeViewerEntry.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/tree/TmfTreeViewerEntry.java @@ -28,8 +28,7 @@ public class TmfTreeViewerEntry implements ITmfTreeViewerEntry { private ITmfTreeViewerEntry fParent = null; /** List of child entries */ - @NonNull - private final List fChildren = new CopyOnWriteArrayList<>(); + private final @NonNull List<@NonNull ITmfTreeViewerEntry> fChildren = new CopyOnWriteArrayList<>(); /** Name of this entry (default text to show in first column) */ private String fName; @@ -68,7 +67,7 @@ public class TmfTreeViewerEntry implements ITmfTreeViewerEntry { } @Override - public List getChildren() { + public List<@NonNull ITmfTreeViewerEntry> getChildren() { return fChildren; } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartAnalysisEntry.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartAnalysisEntry.java index f980f076bb..fde4c706df 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartAnalysisEntry.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartAnalysisEntry.java @@ -12,11 +12,14 @@ package org.eclipse.tracecompass.tmf.ui.views.timechart; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; import java.util.Vector; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent; import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry; @@ -43,7 +46,7 @@ public class TimeChartAnalysisEntry implements ITimeGraphEntry { } @Override - public List getChildren() { + public List<@NonNull ITimeGraphEntry> getChildren() { return null; } @@ -78,16 +81,16 @@ public class TimeChartAnalysisEntry implements ITimeGraphEntry { } @Override - public Iterator getTimeEventsIterator() { + public Iterator<@NonNull ITimeEvent> getTimeEventsIterator() { return new EntryIterator(0, Long.MAX_VALUE, 0); } @Override - public Iterator getTimeEventsIterator(long startTime, long stopTime, long maxDuration) { + public Iterator<@NonNull ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long maxDuration) { return new EntryIterator(startTime, stopTime, maxDuration); } - private class EntryIterator implements Iterator { + private class EntryIterator implements Iterator<@NonNull ITimeEvent> { private final long fIteratorStartTime; private final long fIteratorStopTime; private final long fIteratorMaxDuration; @@ -142,7 +145,7 @@ public class TimeChartAnalysisEntry implements ITimeGraphEntry { return event; } if (hasNext()) { - TimeChartEvent event = next; + TimeChartEvent event = checkNotNull(next); next = null; return event; } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/EventIterator.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/EventIterator.java index ac964f1711..ad5427e9fd 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/EventIterator.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/EventIterator.java @@ -12,10 +12,14 @@ package org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; +import org.eclipse.jdt.annotation.NonNull; + /** * An iterator for time events. Events from the zoomed event list override any @@ -31,7 +35,7 @@ import java.util.NoSuchElementException; * iterator [A][D][E][F] [G][B][C] * */ -public class EventIterator implements Iterator { +public class EventIterator implements Iterator<@NonNull ITimeEvent> { private final long fStartTime; private final long fEndTime; @@ -139,11 +143,11 @@ public class EventIterator implements Iterator { public ITimeEvent next() { if (hasNext()) { if (fZoomedNext != null && (fNext == null || fZoomedNext.getTime() <= fNext.getTime())) { - ITimeEvent event = fZoomedNext; + ITimeEvent event = checkNotNull(fZoomedNext); fZoomedNext = null; return event; } - ITimeEvent event = fNext; + ITimeEvent event = checkNotNull(fNext); fNext = fSplitNext; fSplitNext = null; return event; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/ITimeGraphEntry.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/ITimeGraphEntry.java index f5f662c3ec..cf94fbd823 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/ITimeGraphEntry.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/ITimeGraphEntry.java @@ -16,6 +16,8 @@ package org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model; import java.util.Iterator; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; + /** * Interface for an entry (row) in the time graph view * @@ -44,7 +46,7 @@ public interface ITimeGraphEntry { * * @return an array of child elements */ - List getChildren(); + List<@NonNull ? extends ITimeGraphEntry> getChildren(); /** * Returns the name of this entry. @@ -83,18 +85,22 @@ public interface ITimeGraphEntry { * * @return the iterator */ - Iterator getTimeEventsIterator(); + Iterator<@NonNull ? extends ITimeEvent> getTimeEventsIterator(); /** - * Get an iterator which only returns events that fall within the start time and the stop time. - * The visible duration is the event duration below which further detail is not discernible. - * If no such iterator is implemented, provide a basic iterator which returns all events. + * Get an iterator which only returns events that fall within the start time + * and the stop time. The visible duration is the event duration below which + * further detail is not discernible. If no such iterator is implemented, + * provide a basic iterator which returns all events. * - * @param startTime start time in nanoseconds - * @param stopTime stop time in nanoseconds - * @param visibleDuration duration of one pixel in nanoseconds + * @param startTime + * start time in nanoseconds + * @param stopTime + * stop time in nanoseconds + * @param visibleDuration + * duration of one pixel in nanoseconds * * @return the iterator */ - Iterator getTimeEventsIterator(long startTime, long stopTime, long visibleDuration); + Iterator<@NonNull T> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/TimeGraphEntry.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/TimeGraphEntry.java index 77ef43cf2c..f528974514 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/TimeGraphEntry.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/model/TimeGraphEntry.java @@ -32,7 +32,7 @@ public class TimeGraphEntry implements ITimeGraphEntry { private ITimeGraphEntry fParent = null; /** List of child entries */ - private final List fChildren = new CopyOnWriteArrayList<>(); + private final List<@NonNull ITimeGraphEntry> fChildren = new CopyOnWriteArrayList<>(); /** Name of this entry (text to show) */ private String fName; @@ -97,7 +97,7 @@ public class TimeGraphEntry implements ITimeGraphEntry { } @Override - public synchronized List getChildren() { + public synchronized List<@NonNull ? extends ITimeGraphEntry> getChildren() { return fChildren; } @@ -142,7 +142,7 @@ public class TimeGraphEntry implements ITimeGraphEntry { } @Override - public Iterator getTimeEventsIterator() { + public Iterator<@NonNull ITimeEvent> getTimeEventsIterator() { if (hasTimeEvents()) { return new EventIterator(fEventList, fZoomedEventList); } @@ -150,7 +150,7 @@ public class TimeGraphEntry implements ITimeGraphEntry { } @Override - public Iterator getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) { + public Iterator<@NonNull ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) { if (!hasTimeEvents()) { return null; } @@ -258,7 +258,7 @@ public class TimeGraphEntry implements ITimeGraphEntry { /* * TODO: This method can be removed in the next major API version. */ - public synchronized void addChild(TimeGraphEntry child) { + public synchronized void addChild(@NonNull TimeGraphEntry child) { addChild((ITimeGraphEntry) child); } @@ -270,7 +270,7 @@ public class TimeGraphEntry implements ITimeGraphEntry { * @param child * The child entry */ - public synchronized void addChild(ITimeGraphEntry child) { + public synchronized void addChild(@NonNull ITimeGraphEntry child) { /* * TODO: Use setParent() once it is added to the interface. */ @@ -299,7 +299,7 @@ public class TimeGraphEntry implements ITimeGraphEntry { * @param child * The child entry */ - public synchronized void addChild(int index, ITimeGraphEntry child) { + public synchronized void addChild(int index, @NonNull ITimeGraphEntry child) { /* * TODO: Use setParent() once it is added to the interface. */ @@ -322,7 +322,7 @@ public class TimeGraphEntry implements ITimeGraphEntry { if (comparator == null) { return; } - ITimeGraphEntry[] array = fChildren.toArray(new ITimeGraphEntry[0]); + @NonNull ITimeGraphEntry[] array = fChildren.toArray(new @NonNull ITimeGraphEntry[0]); Arrays.sort(array, comparator); fChildren.clear(); fChildren.addAll(Arrays.asList(array)); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/Utils.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/Utils.java index 720fc8d1f8..94d2cf6f7d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/Utils.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/Utils.java @@ -524,7 +524,7 @@ public class Utils { if (null == entry || ! entry.hasTimeEvents()) { return null; } - Iterator iterator = entry.getTimeEventsIterator(); + Iterator iterator = entry.getTimeEventsIterator(); if (iterator != null && iterator.hasNext()) { return iterator.next(); } @@ -550,7 +550,7 @@ public class Utils { if (null == entry || ! entry.hasTimeEvents()) { return null; } - Iterator iterator = entry.getTimeEventsIterator(); + Iterator iterator = entry.getTimeEventsIterator(); if (iterator == null) { return null; } -- 2.34.1