tmf: Make custom trace output column name @NonNull
authorPatrick Tasse <patrick.tasse@gmail.com>
Thu, 2 Jul 2015 20:18:29 +0000 (16:18 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 7 Jul 2015 14:49:45 +0000 (10:49 -0400)
Change-Id: Ibe9600a9b80833a860c361320d5d755d148e2711
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/51302
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTraceDefinition.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTraceDefinition.java
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java

index 060532013c46fb7f040cc7f21a68b547055ca503..26a79159ffde66a342f48bec8204f57596b8534c 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2014 Ericsson
+ * Copyright (c) 2010, 2015 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -94,9 +94,7 @@ public class CustomEventAspects {
         List<OutputColumn> outputs = definition.outputs;
         for (int i = 0; i < outputs.size(); i++) {
             String name = outputs.get(i).name;
-            if (name != null) {
-                builder.add(new CustomEventFieldAspect(name, i));
-            }
+            builder.add(new CustomEventFieldAspect(name, i));
         }
         return checkNotNull(builder.build());
     }
index 11f7a6ca57c5bcaa17e7a906e044173e65fe01b1..93ef98ec644f687f0c741d0f827a73d57563f268 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2014 Ericsson
+ * Copyright (c) 2010, 2015 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -16,6 +16,7 @@ import java.io.ByteArrayInputStream;
 import java.text.SimpleDateFormat;
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.ErrorHandler;
@@ -66,19 +67,21 @@ public abstract class CustomTraceDefinition {
     public static class OutputColumn {
 
         /** Name of this column */
-        public String name;
+        public @NonNull String name;
 
         /**
          * Default constructor (empty)
          */
-        public OutputColumn() {}
+        public OutputColumn() {
+            this(""); //$NON-NLS-1$
+        }
 
         /**
          * Constructor
          *
          * @param name Name of this output column
          */
-        public OutputColumn(String name) {
+        public OutputColumn(@NonNull String name) {
             this.name = name;
         }
 
index 8bbfcb6980360a617969e0b580e1e84d0b519c94..f2fa3e019c8bcdb0ed1852b23f09f1bcbc1251ce 100644 (file)
@@ -13,6 +13,8 @@
 
 package org.eclipse.tracecompass.tmf.core.parsers.custom;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -809,7 +811,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition {
             } else if (nodeName.equals(OUTPUT_COLUMN_ELEMENT)) {
                 Element outputColumnElement = (Element) node;
                 OutputColumn outputColumn = new OutputColumn();
-                outputColumn.name = outputColumnElement.getAttribute(NAME_ATTRIBUTE);
+                outputColumn.name = checkNotNull(outputColumnElement.getAttribute(NAME_ATTRIBUTE));
                 def.outputs.add(outputColumn);
             }
         }
index 19263f4ffd2db30e80db0cca2db2eb0f2d60465e..47cc6faa55c98876e851fba136140da00bd394c0 100644 (file)
@@ -13,6 +13,8 @@
 
 package org.eclipse.tracecompass.tmf.core.parsers.custom;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -520,7 +522,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition {
             } else if (nodeName.equals(OUTPUT_COLUMN_ELEMENT)) {
                 Element outputColumnElement = (Element) node;
                 OutputColumn outputColumn = new OutputColumn();
-                outputColumn.name = outputColumnElement.getAttribute(NAME_ATTRIBUTE);
+                outputColumn.name = checkNotNull(outputColumnElement.getAttribute(NAME_ATTRIBUTE));
                 def.outputs.add(outputColumn);
             }
         }
index aea1ac827bfe3880812a74924d97dcd010c61877..2a637b95615e1e96f9e0855b250987e9c3d3c9f9 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2014 Ericsson
+ * Copyright (c) 2010, 2015 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.internal.tmf.ui.parsers.wizards;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -262,7 +264,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage {
             final Output output = outputs.get(i);
             if (output.enabledButton.getSelection()) {
                 final OutputColumn column = new OutputColumn();
-                column.name = output.nameLabel.getText();
+                column.name = checkNotNull(output.nameLabel.getText());
                 outputColumns.add(column);
             }
         }
index a74ab58d75ab640ba28de5250c3e1f30d70beb35..bcf746899f28c168b6bcc5e3350901ba90faaffc 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2014 Ericsson
+ * Copyright (c) 2010, 2015 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.internal.tmf.ui.parsers.wizards;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -263,7 +265,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage {
             final Output output = outputs.get(i);
             if (output.enabledButton.getSelection()) {
                 final OutputColumn column = new OutputColumn();
-                column.name = output.nameLabel.getText();
+                column.name = checkNotNull(output.nameLabel.getText());
                 outputColumns.add(column);
             }
         }
This page took 0.031364 seconds and 5 git commands to generate.