tmf: Change getTracesToBuild trace parameter to be @Nullable
authorPatrick Tasse <patrick.tasse@gmail.com>
Thu, 28 Jul 2016 20:56:44 +0000 (16:56 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Fri, 29 Jul 2016 16:14:45 +0000 (12:14 -0400)
The default implementation already handles a null trace, and
VirtualMachineView overrides it as @Nullable.

This allows subclasses to call the method with the return value of
getTrace(), which can be null, without needing a null check and get an
empty list back.

Change-Id: Ie7cb5c79bb841796be4e20fcafedb43ad8b2c839
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/78104
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java

index 0f1b9dcd90b024b69188238e251b2d7e2338edbf..1324fbdb2f31c85337f722591a7dc812b943b9d3 100644 (file)
@@ -29,6 +29,7 @@ import java.util.TreeSet;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.widgets.Composite;
@@ -571,12 +572,12 @@ public class XmlTimeGraphView extends AbstractTimeGraphView {
     }
 
     @Override
-    protected @NonNull Iterable<ITmfTrace> getTracesToBuild(@NonNull ITmfTrace trace) {
+    protected @NonNull Iterable<ITmfTrace> getTracesToBuild(@Nullable ITmfTrace trace) {
         /*
          * Return the current trace only. Experiments will return their
          * children's analyses
          */
-        return Collections.singleton(trace);
+        return (trace != null) ? Collections.singleton(trace) : Collections.EMPTY_LIST;
     }
 
 }
index fc361c2247425b11346ae9159d720b0a350e458f..6865e702d4f6a8c6e21a9393cf46e03b874ae2a9 100644 (file)
@@ -1649,10 +1649,10 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
      * some of which may receive events in live streaming mode.
      *
      * @param trace
-     *            The trace associated with this view
+     *            The trace associated with this view, can be null
      * @return List of traces with data to display
      */
-    protected @NonNull Iterable<ITmfTrace> getTracesToBuild(@NonNull ITmfTrace trace) {
+    protected @NonNull Iterable<ITmfTrace> getTracesToBuild(@Nullable ITmfTrace trace) {
         return TmfTraceManager.getTraceSet(trace);
     }
 
This page took 0.033254 seconds and 5 git commands to generate.