Use the NonNull utility methods where we can
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 2 Dec 2014 13:58:28 +0000 (08:58 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 16 Dec 2014 19:20:30 +0000 (14:20 -0500)
This could allows us to bump the "check conversion of non-annotated
type to @NonNull" warning to error, but we can't at the moment because
of bug 453474.

Change-Id: If3265067e68627b6379770fb5503259760c67b18
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/37618
Reviewed-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
72 files changed:
org.eclipse.tracecompass.btf.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventAspects.java
org.eclipse.tracecompass.ctf.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/io/BitBuffer.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/scope/LexicalScope.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/IntegerDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDefinition.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ByteArrayDefinition.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java
org.eclipse.tracecompass.gdbtrace.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/GdbEventAspects.java
org.eclipse.tracecompass.lttng2.kernel.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/trace/layout/LttngEventLayout.java
org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/trace/layout/PerfEventLayout.java
org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/lttng2/kernel/core/analysis/kernel/LttngKernelAnalysis.java
org.eclipse.tracecompass.lttng2.kernel.ui/META-INF/MANIFEST.MF
org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/cpuusage/CpuUsageComposite.java
org.eclipse.tracecompass.lttng2.ust.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/analysis/memory/UstMemoryAnalysisModule.java
org.eclipse.tracecompass.pcap.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ethernet2/EthernetIIPacket.java
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ipv4/IPv4Endpoint.java
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/ipv4/IPv4Packet.java
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/pcap/PcapPacket.java
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/tcp/TCPEndpoint.java
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/tcp/TCPPacket.java
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/udp/UDPEndpoint.java
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/udp/UDPPacket.java
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/protocol/unknown/UnknownPacket.java
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/stream/PacketStream.java
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/trace/PcapFile.java
org.eclipse.tracecompass.pcap.core/src/org/eclipse/tracecompass/internal/pcap/core/util/ConversionHelper.java
org.eclipse.tracecompass.releng-site/category.xml
org.eclipse.tracecompass.tmf.analysis.xml.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateValue.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyStateValue.java
org.eclipse.tracecompass.tmf.analysis.xml.ui/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java
org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/module/TmfAnalysisModuleHelperXml.java
org.eclipse.tracecompass.tmf.core.tests/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/analysis/AnalysisModuleTestHelper.java
org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/analysis/TmfAnalysisModuleSourceConfigElement.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAbstractAnalysisModule.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/analysis/TmfAnalysisManager.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/component/TmfEventProvider.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventField.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/aspect/TmfStateSystemAspect.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/matching/TcpEventKey.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/text/TextTraceEventContent.java
org.eclipse.tracecompass.tmf.ctf.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/trace/CtfTmfTrace.java
org.eclipse.tracecompass.tmf.pcap.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEvent.java
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEventType.java
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapProtocolAspect.java
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/trace/PcapTrace.java
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/util/PcapEventFactory.java
org.eclipse.tracecompass.tmf.pcap.ui/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/NetworkingPerspectiveFactory.java
org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/stream/StreamListView.java
org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/TmfEventsEditor.java
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/columns/TmfEventTableColumn.java
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java

index d1ea5209bedae469a2418442dc7e54e1a20ac593..16ab322f7b66d4a615986f5c27bc838e34ef288b 100644 (file)
@@ -10,6 +10,7 @@ Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.core.resources,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core;bundle-version="0.1.0"
 Export-Package: org.eclipse.tracecompass.btf.core,
  org.eclipse.tracecompass.btf.core.analysis,
index 5b5ab35e3e8104f4c2158c775bc690d6bf64fe4d..ac577f4c1f709518779c8a34eca70504495143d7 100644 (file)
@@ -15,6 +15,7 @@ package org.eclipse.tracecompass.btf.core.trace;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.btf.core.event.BtfEvent;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.event.aspect.TmfEventFieldAspect;
@@ -30,17 +31,17 @@ public final class BtfEventAspects {
 
     private BtfEventAspects() {}
 
-    @SuppressWarnings("null")
-    private static final @NonNull Iterable<ITmfEventAspect> BTF_ASPECTS = ImmutableList.of(
-            ITmfEventAspect.BaseAspects.TIMESTAMP,
-            new BtfSourceAspect(),
-            new BtfSourceInstanceAspect(),
-            ITmfEventAspect.BaseAspects.EVENT_TYPE,
-            new BtfTargetAspect(),
-            new BtfTargetInstanceAspect(),
-            new BtfEventAspect(),
-            new BtfNotesAspect()
-            );
+    private static final @NonNull Iterable<ITmfEventAspect> BTF_ASPECTS =
+            NonNullUtils.checkNotNull(ImmutableList.of(
+                    ITmfEventAspect.BaseAspects.TIMESTAMP,
+                    new BtfSourceAspect(),
+                    new BtfSourceInstanceAspect(),
+                    ITmfEventAspect.BaseAspects.EVENT_TYPE,
+                    new BtfTargetAspect(),
+                    new BtfTargetInstanceAspect(),
+                    new BtfEventAspect(),
+                    new BtfNotesAspect()
+                    ));
 
     /**
      * The "source" aspect, whose value comes from {@link ITmfEvent#getSource()}
index 33d9885500ba401dd29ea7a10e734d0cb3643a50..73e4f6cd518e995baa7151f44c0af8c9c3373d3e 100644 (file)
@@ -9,8 +9,8 @@ Bundle-Activator: org.eclipse.tracecompass.internal.ctf.core.Activator
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.tracecompass.ctf.parser;bundle-version="0.1.0",
- org.eclipse.tracecompass.common.core
+ org.eclipse.tracecompass.common.core,
+ org.eclipse.tracecompass.ctf.parser;bundle-version="0.1.0"
 Export-Package: org.eclipse.tracecompass.ctf.core,
  org.eclipse.tracecompass.ctf.core.event,
  org.eclipse.tracecompass.ctf.core.event.io,
index 91448bc4e45e9a2db6357c06ed8df3486fec146a..ceddaea0e004afc5dcd6dc4add70ebd7e320dc47 100644 (file)
@@ -15,6 +15,8 @@
 
 package org.eclipse.tracecompass.ctf.core.event.io;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.nio.BufferUnderflowException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
@@ -63,9 +65,8 @@ public final class BitBuffer {
     /**
      * Default constructor, makes a big-endian buffer
      */
-    @SuppressWarnings("null")
     public BitBuffer() {
-        this(ByteBuffer.allocateDirect(0), ByteOrder.BIG_ENDIAN);
+        this(checkNotNull(ByteBuffer.allocateDirect(0)), ByteOrder.BIG_ENDIAN);
     }
 
     /**
index bdfcadc3f20d45139567b411b748ae2f2fcf9c7b..43bb1001d66f4a7b03aa0f972580544a7e4775d6 100644 (file)
 
 package org.eclipse.tracecompass.ctf.core.event.scope;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
@@ -183,11 +186,10 @@ public class LexicalScope implements Comparable<LexicalScope> {
      * @param name
      *            the name of the field
      */
-    @SuppressWarnings("null")
     public LexicalScope(@Nullable LexicalScope parent, String name) {
         fName = name;
         if (parent != null) {
-            String pathString = Joiner.on('.').skipNulls().join(parent.fPath, parent.getName());
+            @NonNull String pathString = checkNotNull(Joiner.on('.').skipNulls().join(parent.fPath, parent.getName()));
             /*
              * if joiner return null, we get an NPE... so we won't assign fPath
              * to null
@@ -197,7 +199,7 @@ public class LexicalScope implements Comparable<LexicalScope> {
                  * substring throws an exception or returns a string, it won't
                  * return null
                  */
-                pathString = pathString.substring(1);
+                pathString = checkNotNull(pathString.substring(1));
             }
             fPath = pathString;
             parent.addChild(fName, this);
index 191a209e1d69e75665826c340ef07a68b5805d20..017e70816c1b1625418225c885655d031125ae45 100644 (file)
 
 package org.eclipse.tracecompass.ctf.core.event.types;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.math.BigInteger;
 import java.nio.ByteOrder;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
@@ -280,10 +281,7 @@ public final class IntegerDeclaration extends Declaration implements ISimpleData
         fSigned = signed;
         fBase = base;
 
-        @SuppressWarnings("null")
-        @NonNull
-        ByteOrder actualByteOrder = (byteOrder == null ? ByteOrder.nativeOrder() : byteOrder);
-        fByteOrder = actualByteOrder;
+        fByteOrder = (byteOrder == null ? checkNotNull(ByteOrder.nativeOrder()) : byteOrder);
 
         fEncoding = encoding;
         fClock = clock;
@@ -422,11 +420,7 @@ public final class IntegerDeclaration extends Declaration implements ISimpleData
          * For a given N significant bits, compute the maximal value which is (1
          * << N) - 1.
          */
-
-        @SuppressWarnings("null")
-        @NonNull
-        BigInteger ret = BigInteger.ONE.shiftLeft(significantBits).subtract(BigInteger.ONE);
-        return ret;
+        return checkNotNull(BigInteger.ONE.shiftLeft(significantBits).subtract(BigInteger.ONE));
     }
 
     /**
@@ -437,10 +431,7 @@ public final class IntegerDeclaration extends Declaration implements ISimpleData
      */
     public BigInteger getMinValue() {
         if (!fSigned) {
-            @SuppressWarnings("null")
-            @NonNull
-            BigInteger ret = BigInteger.ZERO;
-            return ret;
+            return checkNotNull(BigInteger.ZERO);
         }
 
         /*
@@ -452,10 +443,7 @@ public final class IntegerDeclaration extends Declaration implements ISimpleData
          * For a given N significant bits, compute the minimal value which is -
          * (1 << N).
          */
-        @SuppressWarnings("null")
-        @NonNull
-        BigInteger ret = BigInteger.ONE.shiftLeft(significantBits).negate();
-        return ret;
+        return checkNotNull(BigInteger.ONE.shiftLeft(significantBits).negate());
     }
 
     private long read(BitBuffer input) throws CTFReaderException {
index 9aa5a6521ca86ba382b25201ebb39df5200d6bd9..6c9d29c30570d0775bc2c1e0f2143023af1ea784 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.ctf.core.event.types;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
@@ -194,11 +196,9 @@ public class StructDeclaration extends Declaration {
             LexicalScope fieldScope, @NonNull BitBuffer input) throws CTFReaderException {
         alignRead(input);
         final Definition[] myFields = new Definition[fFieldMap.size()];
-        /*
-         * Key set is NOT null
-         */
-        @SuppressWarnings("null")
-        StructDefinition structDefinition = new StructDefinition(this, definitionScope, fieldScope, fieldScope.getName(), fFieldMap.keySet(), myFields);
+
+        StructDefinition structDefinition = new StructDefinition(this,definitionScope,
+                fieldScope, fieldScope.getName(), checkNotNull(fFieldMap.keySet()), myFields);
         fillStruct(input, myFields, structDefinition);
         return structDefinition;
     }
@@ -216,12 +216,13 @@ public class StructDeclaration extends Declaration {
         fMaxAlign = Math.max(fMaxAlign, declaration.getAlignment());
     }
 
-    @SuppressWarnings("null")
     private void fillStruct(@NonNull BitBuffer input, final Definition[] myFields, StructDefinition structDefinition) throws CTFReaderException {
         Iterator<Map.Entry<String, IDeclaration>> iter = fFieldMap.entrySet().iterator();
         for (int i = 0; i < fFieldMap.size(); i++) {
             Map.Entry<String, IDeclaration> entry = iter.next();
-            myFields[i] = entry.getValue().createDefinition(structDefinition, entry.getKey(), input);
+            /* We should not have inserted null keys... */
+            String key = checkNotNull(entry.getKey());
+            myFields[i] = entry.getValue().createDefinition(structDefinition, key, input);
         }
     }
 
index 841c6b212794e040878b7e8f8aecfaa971f22f50..ab55860cc11a5780a85b1b75d217d49b785156ca 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.internal.ctf.core.event.types;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNull;
@@ -133,10 +135,7 @@ public final class ArrayDeclaration extends CompoundDeclaration {
             }
             definitions.add(fElemType.createDefinition(definitionScope, name, input));
         }
-        @SuppressWarnings("null")
-        @NonNull
-        ImmutableList<Definition> ret = definitions.build();
-        return ret;
+        return checkNotNull(definitions.build());
     }
 
     @Override
index 6caba340d7f0b10632b548686cb03e3ccb8dcd9b..ebb2b068da9cc0e0a46060756c47861a9cd16d33 100644 (file)
 
 package org.eclipse.tracecompass.internal.ctf.core.event.types;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.List;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
@@ -44,7 +45,7 @@ public final class ArrayDefinition extends AbstractArrayDefinition {
     // Attributes
     // ------------------------------------------------------------------------
 
-    private final ImmutableList<Definition> fDefinitions;
+    private final List<Definition> fDefinitions;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -67,9 +68,7 @@ public final class ArrayDefinition extends AbstractArrayDefinition {
             String fieldName,
             List<Definition> definitions) {
         super(declaration, definitionScope, fieldName);
-        @SuppressWarnings("null")
-        @NonNull ImmutableList<Definition> list = ImmutableList.copyOf(definitions);
-        fDefinitions = list;
+        fDefinitions = checkNotNull(ImmutableList.copyOf(definitions));
     }
 
     // ------------------------------------------------------------------------
@@ -101,8 +100,6 @@ public final class ArrayDefinition extends AbstractArrayDefinition {
         Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$
         b.append(joiner.join(fDefinitions));
         b.append(']');
-        @SuppressWarnings("null")
-        @NonNull String ret = b.toString();
-        return ret;
+        return checkNotNull(b.toString());
     }
 }
\ No newline at end of file
index b6ac66eb144d32792e7f0d13a37009e7f569e63d..5c1be44a2fe645f79e189193d7588ac1f9e3cb3e 100644 (file)
@@ -15,9 +15,9 @@ package org.eclipse.tracecompass.internal.ctf.core.event.types;
 import java.util.Arrays;
 import java.util.List;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
 import org.eclipse.tracecompass.ctf.core.event.types.AbstractArrayDefinition;
 import org.eclipse.tracecompass.ctf.core.event.types.CompoundDeclaration;
@@ -72,10 +72,8 @@ public final class ByteArrayDefinition extends AbstractArrayDefinition {
                 byte fieldValue = fContent[i];
                 builder.add(new IntegerDefinition(charDecl, getDefinitionScope(), fieldName, fieldValue));
             }
-            @SuppressWarnings("null")
-            @NonNull List<Definition> ret = builder.build();
-            fDefs = ret;
-            return ret;
+            fDefs = NonNullUtils.checkNotNull(builder.build());
+            return fDefs;
         }
 
         return defs;
index 75bb207f8f66e5ff34d56aebea4b3916cfdd7d40..186e2601538c14590d1a1fa1f1ac1c6a29132413 100644 (file)
 
 package org.eclipse.tracecompass.internal.ctf.core.event.types;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.Collection;
 import java.util.List;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
@@ -130,14 +131,12 @@ public class SequenceDeclaration extends CompoundDeclaration {
         List<String> paths = (List<String>) fPaths.get(fieldName);
         Builder<Definition> definitions = new ImmutableList.Builder<>();
         for (int i = 0; i < length; i++) {
-            @SuppressWarnings("null")
-            @NonNull
-            String elemName = paths.get(i);
+            /* We should not have inserted any null values */
+            String elemName = checkNotNull(paths.get(i));
             definitions.add(fElemType.createDefinition(definitionScope, elemName, input));
         }
-        @SuppressWarnings("null")
-        @NonNull ImmutableList<Definition> build = definitions.build();
-        return new ArrayDefinition(this, definitionScope, fieldName, build);
+        List<Definition> list = checkNotNull(definitions.build());
+        return new ArrayDefinition(this, definitionScope, fieldName, list);
     }
 
     @Override
index b9ead48963d7f16faadabc526a53847120345222..90a400412485c8b56182638d5589132fe7c017a1 100644 (file)
@@ -10,6 +10,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.ui.ide,
  org.eclipse.debug.core,
  org.eclipse.debug.ui,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core;bundle-version="0.1.0",
  org.eclipse.tracecompass.tmf.ui;bundle-version="0.1.0",
  org.eclipse.cdt.dsf,
index 9debbec986e65c01d1cd88888f093784297202b8..56911095545fa7955d4ba8c22ce0a41e92a405f5 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.internal.gdbtrace.core.trace;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEvent;
 import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEventContent;
@@ -30,12 +32,12 @@ public final class GdbEventAspects {
 
     private GdbEventAspects() {}
 
-    @SuppressWarnings("null")
-    private static final @NonNull Iterable<ITmfEventAspect> GDB_ASPECTS = ImmutableList.of(
-            new GdbTraceFrameAspect(),
-            new GdbTracepointAspect(),
-            new GdbFileAspect()
-            );
+    private static final @NonNull Iterable<ITmfEventAspect> GDB_ASPECTS =
+            checkNotNull(ImmutableList.of(
+                    new GdbTraceFrameAspect(),
+                    new GdbTracepointAspect(),
+                    new GdbFileAspect()
+                    ));
 
     private static class GdbTraceFrameAspect extends TmfEventFieldAspect {
         public GdbTraceFrameAspect() {
index 94273747794e2be7dfe7de33cc457c39149bec36..252b442f42621849c4fcfdf7f6df17cbf1ee8072 100644 (file)
@@ -10,6 +10,7 @@ Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.core.resources,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.ctf.core;bundle-version="0.1.0",
  org.eclipse.tracecompass.tmf.core;bundle-version="0.1.0",
  org.eclipse.tracecompass.tmf.ctf.core,
index 494216c0ed08400acdcb8c504fd8964c385af3c2..529a5a770e15ce11fdc3a40dbe55e172f103d470 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.Collection;
 
 import org.eclipse.jdt.annotation.NonNull;
@@ -39,8 +41,8 @@ public class LttngEventLayout implements IKernelAnalysisEventLayout {
     private static final String SOFTIRQ_RAISE = "softirq_raise";
     private static final String SCHED_SWITCH = "sched_switch";
 
-    @SuppressWarnings("null")
-    private static final @NonNull Collection<String> SCHED_WAKEUP_EVENTS = ImmutableList.of("sched_wakeup", "sched_wakeup_new");
+    private static final Collection<String> SCHED_WAKEUP_EVENTS =
+            checkNotNull(ImmutableList.of("sched_wakeup", "sched_wakeup_new"));
 
     private static final String SCHED_PROCESS_FORK = "sched_process_fork";
     private static final String SCHED_PROCESS_EXIT = "sched_process_exit";
index bd39d2f39bbeed88baa45ba2b8f12e7d91ca3ca3..db77bfac4bb2d9c18f7793b68d1ac48d8c4c061d 100644 (file)
 
 package org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.Collection;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 
 import com.google.common.collect.ImmutableList;
@@ -73,9 +74,8 @@ public class PerfEventLayout implements IKernelAnalysisEventLayout {
         return "sched:sched_switch"; //$NON-NLS-1$
     }
 
-    @SuppressWarnings("null")
-    private static final @NonNull Collection<String> WAKEUP_EVENTS = ImmutableList.of(
-            "sched:sched_wakeup", "sched:sched_wakeup_new"); //$NON-NLS-1$ //$NON-NLS-2$
+    private static final Collection<String> WAKEUP_EVENTS =
+            checkNotNull(ImmutableList.of("sched:sched_wakeup", "sched:sched_wakeup_new")); //$NON-NLS-1$ //$NON-NLS-2$
 
     @Override
     public Collection<String> eventsSchedWakeup() {
index 5ef742900d997c9bead93b3bad393d9ead15b809..8f3ea2d3a975764776596ef3fb857ad3a359f2ac 100644 (file)
 
 package org.eclipse.tracecompass.lttng2.kernel.core.analysis.kernel;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.util.Set;
+
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.IKernelAnalysisEventLayout;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
 import org.eclipse.tracecompass.lttng2.control.core.session.SessionConfigStrings;
@@ -70,7 +75,7 @@ public class LttngKernelAnalysis extends TmfStateSystemAnalysisModule {
             );
 
     /** The requirements as an immutable set */
-    private static final @NonNull ImmutableSet<TmfAnalysisRequirement> REQUIREMENTS;
+    private static final @NonNull Set<TmfAnalysisRequirement> REQUIREMENTS;
 
     static {
         /* initialize the requirement: domain and events */
@@ -80,10 +85,7 @@ public class LttngKernelAnalysis extends TmfStateSystemAnalysisModule {
         TmfAnalysisRequirement eventReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_EVENT, REQUIRED_EVENTS, ValuePriorityLevel.MANDATORY);
         eventReq.addValues(OPTIONAL_EVENTS, ValuePriorityLevel.OPTIONAL);
 
-
-        @SuppressWarnings("null")
-        @NonNull ImmutableSet<TmfAnalysisRequirement> reqSet = ImmutableSet.of(domainReq, eventReq);
-        REQUIREMENTS = reqSet;
+        REQUIREMENTS = checkNotNull(ImmutableSet.of(domainReq, eventReq));
     }
 
     @Override
@@ -109,9 +111,7 @@ public class LttngKernelAnalysis extends TmfStateSystemAnalysisModule {
 
     @Override
     protected String getFullHelpText() {
-        @SuppressWarnings("null")
-        @NonNull String helpText = Messages.LttngKernelAnalysisModule_Help;
-        return helpText;
+        return NonNullUtils.nullToEmptyString(Messages.LttngKernelAnalysisModule_Help);
     }
 
     @Override
index 6281287e35205a2c68ef81daeff27ad1ee8c0089..56e47cf0a55803c18e7b60f895a97a3bafad4b50 100644 (file)
@@ -12,6 +12,7 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.ui.ide,
  org.eclipse.core.resources,
  org.eclipse.core.runtime,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core;bundle-version="0.1.0",
  org.eclipse.tracecompass.tmf.ui;bundle-version="0.1.0",
  org.eclipse.tracecompass.tmf.ctf.core;bundle-version="0.1.0",
index 182e3c6e2a90b2dd1d2218fd3d04f264bd1abb32..a565ca1539ff782b4f56225b2506519e2ecd4089 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.internal.lttng2.kernel.ui.views.cpuusage;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -19,7 +21,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerComparator;
 import org.eclipse.osgi.util.NLS;
@@ -183,8 +184,7 @@ public class CpuUsageComposite extends AbstractTmfTreeViewer {
             for (ITmfTreeViewerEntry entry : rootEntry.getChildren()) {
                 if (entry instanceof CpuUsageEntry) {
                     if (selectedThread.equals(((CpuUsageEntry) entry).getTid())) {
-                        @SuppressWarnings("null")
-                        @NonNull List<ITmfTreeViewerEntry> list = Collections.singletonList(entry);
+                        List<ITmfTreeViewerEntry> list = checkNotNull(Collections.singletonList(entry));
                         super.setSelection(list);
                         return;
                     }
index 00077002be93f0f24d8dbf14d8a453052b821114..d49817133de9e9016f68e81d1f087852d458509a 100644 (file)
@@ -15,6 +15,7 @@ Export-Package: org.eclipse.tracecompass.internal.lttng2.ust.core;x-internal:=tr
  org.eclipse.tracecompass.lttng2.ust.core.trace
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.core.resources,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.ctf.core;bundle-version="0.1.0",
  org.eclipse.tracecompass.tmf.core;bundle-version="0.1.0",
  org.eclipse.tracecompass.tmf.ctf.core,
index bf47ebcd3365cb738538d0dc2c1844c93f2348dc..e6ec22e504f377d88736be1cc0382c5ebe666cae 100644 (file)
 
 package org.eclipse.tracecompass.lttng2.ust.core.analysis.memory;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
+import java.util.Set;
+
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.lttng2.ust.core.memoryusage.MemoryUsageStateProvider;
 import org.eclipse.tracecompass.internal.lttng2.ust.core.memoryusage.UstMemoryStrings;
@@ -51,7 +55,7 @@ public class UstMemoryAnalysisModule extends TmfStateSystemAnalysisModule {
             );
 
     /** The requirements as an immutable set */
-    private static final @NonNull ImmutableSet<TmfAnalysisRequirement> REQUIREMENTS;
+    private static final @NonNull Set<TmfAnalysisRequirement> REQUIREMENTS;
 
     static {
         /* Initialize the requirements for the analysis: domain and events */
@@ -67,9 +71,7 @@ public class UstMemoryAnalysisModule extends TmfStateSystemAnalysisModule {
         TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN);
         domainReq.addValue(SessionConfigStrings.CONFIG_DOMAIN_TYPE_UST, ValuePriorityLevel.MANDATORY);
 
-        @SuppressWarnings("null")
-        @NonNull ImmutableSet<TmfAnalysisRequirement> reqSet = ImmutableSet.of(domainReq, eventsReq);
-        REQUIREMENTS = reqSet;
+        REQUIREMENTS = checkNotNull(ImmutableSet.of(domainReq, eventsReq));
     }
 
     @Override
index 5ece1a375080ea47c3acf0e937654d6cfd10cd8f..1b57c178a03019e57eacf2928e542e12c3bebffa 100644 (file)
@@ -9,7 +9,8 @@ Bundle-Activator: org.eclipse.tracecompass.internal.pcap.core.Activator
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.core.resources
+ org.eclipse.core.resources,
+ org.eclipse.tracecompass.common.core
 Export-Package: org.eclipse.tracecompass.internal.pcap.core;x-friends:="org.eclipse.tracecompass.pcap.core.tests",
  org.eclipse.tracecompass.internal.pcap.core.endpoint;x-friends:="org.eclipse.tracecompass.tmf.pcap.core",
  org.eclipse.tracecompass.internal.pcap.core.filter;x-internal:=true,
index 95cf4cb661df4402b21c6dbe415f06d25c174c17..f2957b593698909c4b9e4f09a4c9a88b56134df7 100644 (file)
 
 package org.eclipse.tracecompass.internal.pcap.core.protocol.ethernet2;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.nio.ByteBuffer;
 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.internal.pcap.core.packet.BadPacketException;
 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
@@ -52,7 +53,7 @@ public class EthernetIIPacket extends Packet {
     private @Nullable EthernetIIEndpoint fSourceEndpoint;
     private @Nullable EthernetIIEndpoint fDestinationEndpoint;
 
-    private @Nullable ImmutableMap<String, String> fFields;
+    private @Nullable Map<String, String> fFields;
 
     /**
      * Constructor of the Ethernet Packet class.
@@ -124,9 +125,7 @@ public class EthernetIIPacket extends Packet {
      * @return The source MAC address.
      */
     public byte[] getSourceMacAddress() {
-        @SuppressWarnings("null")
-        @NonNull byte[] mac = Arrays.copyOf(fSourceMacAddress, fSourceMacAddress.length);
-        return mac;
+        return checkNotNull(Arrays.copyOf(fSourceMacAddress, fSourceMacAddress.length));
     }
 
     /**
@@ -135,9 +134,7 @@ public class EthernetIIPacket extends Packet {
      * @return The destination MAC address.
      */
     public byte[] getDestinationMacAddress() {
-        @SuppressWarnings("null")
-        @NonNull byte[] mac = Arrays.copyOf(fDestinationMacAddress, fDestinationMacAddress.length);
-        return mac;
+        return checkNotNull(Arrays.copyOf(fDestinationMacAddress, fDestinationMacAddress.length));
     }
 
     /**
@@ -208,16 +205,15 @@ public class EthernetIIPacket extends Packet {
 
     @Override
     public Map<String, String> getFields() {
-        ImmutableMap<String, String> map = fFields;
+        Map<String, String> map = fFields;
         if (map == null) {
-            @SuppressWarnings("null")
-            @NonNull ImmutableMap<String, String> newMap = ImmutableMap.<String, String> builder()
-                    .put("Source MAC Address", ConversionHelper.toMacAddress(fSourceMacAddress)) //$NON-NLS-1$
-                    .put("Destination MAC Address", ConversionHelper.toMacAddress(fDestinationMacAddress)) //$NON-NLS-1$
-                    .put("Ethertype", String.valueOf(EthertypeHelper.toEtherType(fType))) //$NON-NLS-1$
-                    .build();
-            fFields = newMap;
-            return newMap;
+            ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder();
+            builder.put("Source MAC Address", ConversionHelper.toMacAddress(fSourceMacAddress)); //$NON-NLS-1$
+            builder.put("Destination MAC Address", ConversionHelper.toMacAddress(fDestinationMacAddress)); //$NON-NLS-1$
+            builder.put("Ethertype", String.valueOf(EthertypeHelper.toEtherType(fType))); //$NON-NLS-1$
+
+            fFields = checkNotNull(builder.build());
+            return fFields;
         }
         return map;
     }
index f5ab552fe1cd685db9f3e7c2be55d039884f44ab..0acc7b752b4a38ad2dd987973391c3cfe4583563 100644 (file)
 
 package org.eclipse.tracecompass.internal.pcap.core.protocol.ipv4;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.net.Inet4Address;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.pcap.core.endpoint.ProtocolEndpoint;
 
@@ -90,9 +91,7 @@ public class IPv4Endpoint extends ProtocolEndpoint {
     public String toString() {
         ProtocolEndpoint endpoint = getParentEndpoint();
         if (endpoint == null) {
-            @SuppressWarnings("null")
-            @NonNull String ret = fIPAddress.getHostAddress();
-            return ret;
+            return checkNotNull(fIPAddress.getHostAddress());
         }
         return endpoint.toString() + '/' + fIPAddress.getHostAddress();
     }
index 876abac70f933085cc8a5e526e2950b5fce4b502..365004c56b330bfb11fc9c4f5eeca53edf4c178c 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.internal.pcap.core.protocol.ipv4;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.net.Inet4Address;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -20,7 +22,6 @@ 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.internal.pcap.core.packet.BadPacketException;
 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
@@ -65,7 +66,7 @@ public class IPv4Packet extends Packet {
     private @Nullable IPv4Endpoint fSourceEndpoint;
     private @Nullable IPv4Endpoint fDestinationEndpoint;
 
-    private @Nullable ImmutableMap<String, String> fFields;
+    private @Nullable Map<String, String> fFields;
 
     // TODO Interpret options. See
     // http://www.iana.org/assignments/ip-parameters/ip-parameters.xhtml
@@ -124,12 +125,8 @@ public class IPv4Packet extends Packet {
         packet.get(destination);
 
         try {
-            @SuppressWarnings("null")
-            @NonNull Inet4Address sourceIP = (Inet4Address) InetAddress.getByAddress(source);
-            @SuppressWarnings("null")
-            @NonNull Inet4Address destinationIP = (Inet4Address) InetAddress.getByAddress(destination);
-            fSourceIpAddress = sourceIP;
-            fDestinationIpAddress = destinationIP;
+            fSourceIpAddress = (Inet4Address) checkNotNull(InetAddress.getByAddress(source));
+            fDestinationIpAddress = (Inet4Address) checkNotNull(InetAddress.getByAddress(destination));
         } catch (UnknownHostException e) {
             throw new BadPacketException("The IP Address size is not valid!"); //$NON-NLS-1$
         }
@@ -435,7 +432,7 @@ public class IPv4Packet extends Packet {
 
     @Override
     public Map<String, String> getFields() {
-        ImmutableMap<String, String> map = fFields;
+        Map<String, String> map = fFields;
         if (map == null) {
             Builder<String, String> builder = ImmutableMap.<String, String> builder()
                     .put("Version", String.valueOf(fVersion)) //$NON-NLS-1$
@@ -459,11 +456,8 @@ public class IPv4Packet extends Packet {
                 builder.put("Options", ConversionHelper.bytesToHex(options, true)); //$NON-NLS-1$
 
             }
-            @SuppressWarnings("null")
-            @NonNull
-            ImmutableMap<String, String> newMap = builder.build();
-            fFields = newMap;
-            return newMap;
+            fFields = checkNotNull(builder.build());
+            return fFields;
         }
         return map;
     }
index b8120c740382a0feda05690fd86f59fb44c68d8b..237a7c07588410d89b7bb1e062989b50ecb71e46 100644 (file)
@@ -16,8 +16,8 @@ import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 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;
 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
 import org.eclipse.tracecompass.internal.pcap.core.protocol.PcapProtocol;
@@ -53,7 +53,7 @@ public class PcapPacket extends Packet {
     private @Nullable PcapEndpoint fSourceEndpoint;
     private @Nullable PcapEndpoint fDestinationEndpoint;
 
-    private @Nullable ImmutableMap<String, String> fFields;
+    private @Nullable Map<String, String> fFields;
 
     /**
      * Constructor of the Pcap Packet class.
@@ -260,17 +260,16 @@ public class PcapPacket extends Packet {
     // TODO microsec
     @Override
     public Map<String, String> getFields() {
-        ImmutableMap<String, String> map = fFields;
+        Map<String, String> map = fFields;
         if (map == null) {
-            @SuppressWarnings("null")
-            @NonNull ImmutableMap<String, String> newMap = ImmutableMap.<String, String> builder()
-                    .put("Frame", String.valueOf(fPacketIndex)) //$NON-NLS-1$
-                    .put("Frame Length", String.valueOf(fOriginalLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$
-                    .put("Capture Length", String.valueOf(fIncludedLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$
-                    .put("Capture Time", ConversionHelper.toGMTTime(fTimestamp, getTimestampScale())) //$NON-NLS-1$
-                    .build();
-            fFields = newMap;
-            return newMap;
+            ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> 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$
+            builder.put("Capture Time", ConversionHelper.toGMTTime(fTimestamp, getTimestampScale())); //$NON-NLS-1$
+
+            fFields = NonNullUtils.checkNotNull(builder.build());
+            return fFields;
         }
         return map;
     }
index 745ea2d6549814fbd6e02939a60e26acd5d8a847..a5d400413acdc48159b2fd9625c2a987675907cd 100644 (file)
@@ -12,7 +12,8 @@
 
 package org.eclipse.tracecompass.internal.pcap.core.protocol.tcp;
 
-import org.eclipse.jdt.annotation.NonNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.pcap.core.endpoint.ProtocolEndpoint;
 
@@ -86,10 +87,7 @@ public class TCPEndpoint extends ProtocolEndpoint {
     public String toString() {
         ProtocolEndpoint endpoint = getParentEndpoint();
         if (endpoint == null) {
-            @SuppressWarnings("null")
-            @NonNull
-            String ret = String.valueOf(fPort);
-            return ret;
+            return checkNotNull(String.valueOf(fPort));
         }
         return endpoint.toString() + '/' + fPort;
     }
index cd2e88a2d1f5d342cbf9153d54101e2c8471f688..bcf86b36b7a55c6775b843301aa46f25e5c0c591 100644 (file)
 
 package org.eclipse.tracecompass.internal.pcap.core.protocol.tcp;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.nio.ByteBuffer;
 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.internal.pcap.core.packet.BadPacketException;
 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
@@ -62,7 +63,7 @@ public class TCPPacket extends Packet {
     private @Nullable TCPEndpoint fSourceEndpoint;
     private @Nullable TCPEndpoint fDestinationEndpoint;
 
-    private @Nullable ImmutableMap<String, String> fFields;
+    private @Nullable Map<String, String> fFields;
 
     /**
      * Constructor of the TCP Packet class.
@@ -421,7 +422,7 @@ public class TCPPacket extends Packet {
 
     @Override
     public Map<String, String> getFields() {
-        ImmutableMap<String, String> map = fFields;
+        Map<String, String> map = fFields;
         if (map == null) {
             Builder<String, String> builder = ImmutableMap.<String, String> builder()
                     .put("Source Port", String.valueOf(fSourcePort)) //$NON-NLS-1$
@@ -448,10 +449,8 @@ public class TCPPacket extends Packet {
                 builder.put("Options", ConversionHelper.bytesToHex(options, true)); //$NON-NLS-1$
 
             }
-            @SuppressWarnings("null")
-            @NonNull ImmutableMap<String, String> newMap = builder.build();
-            fFields = newMap;
-            return newMap;
+            fFields = checkNotNull(builder.build());
+            return fFields;
         }
         return map;
     }
index fd5c76449fdcf16f1cd1e290a50f3fb326f27016..7367e8a1284565e6aa28b7db015070d5599a1a39 100644 (file)
@@ -12,7 +12,8 @@
 
 package org.eclipse.tracecompass.internal.pcap.core.protocol.udp;
 
-import org.eclipse.jdt.annotation.NonNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.pcap.core.endpoint.ProtocolEndpoint;
 
@@ -86,9 +87,7 @@ public class UDPEndpoint extends ProtocolEndpoint {
     public String toString() {
         ProtocolEndpoint endpoint = getParentEndpoint();
         if (endpoint == null) {
-            @SuppressWarnings("null")
-            @NonNull String ret = String.valueOf(fPort);
-            return ret;
+            return checkNotNull(String.valueOf(fPort));
         }
         return endpoint.toString() + '/' + fPort;
     }
index ecf466c4a2008ed028bdd849f14ff457d9972f55..a0507de11f40986bba5f42231b8ca3e29e01bfcb 100644 (file)
@@ -16,8 +16,8 @@ import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 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;
 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
 import org.eclipse.tracecompass.internal.pcap.core.protocol.PcapProtocol;
@@ -45,7 +45,7 @@ public class UDPPacket extends Packet {
     private @Nullable UDPEndpoint fSourceEndpoint;
     private @Nullable UDPEndpoint fDestinationEndpoint;
 
-    private @Nullable ImmutableMap<String, String> fFields;
+    private @Nullable Map<String, String> fFields;
 
     /**
      * Constructor of the UDP Packet class.
@@ -203,17 +203,16 @@ public class UDPPacket extends Packet {
 
     @Override
     public Map<String, String> getFields() {
-        ImmutableMap<String, String> map = fFields;
+        Map<String, String> map = fFields;
         if (map == null) {
-            @SuppressWarnings("null")
-            @NonNull ImmutableMap<String, String> newMap = ImmutableMap.<String, String> builder()
+            ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder()
                     .put("Source Port", String.valueOf(fSourcePort)) //$NON-NLS-1$
                     .put("Destination Port", String.valueOf(fDestinationPort)) //$NON-NLS-1$
                     .put("Length", String.valueOf(fTotalLength) + " bytes") //$NON-NLS-1$ //$NON-NLS-2$
-                    .put("Checksum", String.format("%s%04x", "0x", fChecksum)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-                    .build();
-            fFields = newMap;
-            return newMap;
+                    .put("Checksum", String.format("%s%04x", "0x", fChecksum)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+            fFields = NonNullUtils.checkNotNull(builder.build());
+            return fFields;
         }
         return map;
     }
index d6a38756fdc5f6c85c2ebadf20c0a64ad5580a12..645484f46845cfa9b601f80d9ed2dbca5134cbf4 100644 (file)
 
 package org.eclipse.tracecompass.internal.pcap.core.protocol.unknown;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.util.Map;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
 import org.eclipse.tracecompass.internal.pcap.core.protocol.PcapProtocol;
@@ -42,7 +43,7 @@ public class UnknownPacket extends Packet {
     private @Nullable UnknownEndpoint fSourceEndpoint;
     private @Nullable UnknownEndpoint fDestinationEndpoint;
 
-    private @Nullable ImmutableMap<String, String> fFields;
+    private @Nullable Map<String, String> fFields;
 
     /**
      * Constructor of an Unknown Packet object.
@@ -87,8 +88,7 @@ public class UnknownPacket extends Packet {
 
     @Override
     public String toString() {
-        @SuppressWarnings("null")
-        @NonNull byte[] array = fPayload.array();
+        byte[] array = checkNotNull(fPayload.array());
         String string = "Payload: " + ConversionHelper.bytesToHex(array, true); //$NON-NLS-1$
         final Packet child = fChildPacket;
         if (child != null) {
@@ -127,10 +127,9 @@ public class UnknownPacket extends Packet {
 
     @Override
     public Map<String, String> getFields() {
-        ImmutableMap<String, String> map = fFields;
+        Map<String, String> map = fFields;
         if (map == null) {
-            @SuppressWarnings("null")
-            @NonNull byte[] array = fPayload.array();
+            byte[] array = checkNotNull(fPayload.array());
 
             Builder<String, String> builder = ImmutableMap.<String, String> builder()
                     .put("Binary", ConversionHelper.bytesToHex(array, true)); //$NON-NLS-1$
@@ -140,10 +139,8 @@ public class UnknownPacket extends Packet {
             } catch (UnsupportedEncodingException e) {
                 // Do nothing. The string won't be added to the map anyway.
             }
-            @SuppressWarnings("null")
-            @NonNull ImmutableMap<String, String> newMap = builder.build();
-            fFields = newMap;
-            return newMap;
+            fFields = checkNotNull(builder.build());
+            return fFields;
         }
         return map;
     }
index 10ca5e32681983969a1c4c6222aea2934ccb0f0d..ddb835a3193b6c357475fb9aa59a6d0c07cfe8df 100644 (file)
@@ -12,7 +12,8 @@
 
 package org.eclipse.tracecompass.internal.pcap.core.stream;
 
-import org.eclipse.jdt.annotation.NonNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import org.eclipse.tracecompass.internal.pcap.core.endpoint.ProtocolEndpointPair;
 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
 import org.eclipse.tracecompass.internal.pcap.core.protocol.PcapProtocol;
@@ -155,9 +156,7 @@ public class PacketStream {
         StringBuilder sb = new StringBuilder();
         sb.append("Stream " + getUniqueID() + ", Number of Packets: " + getNbPackets() + "\n"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
 
-        @SuppressWarnings("null")
-        @NonNull String string = sb.toString();
-        return string;
+        return checkNotNull(sb.toString());
 
     }
 
index cfb8517db55a3c491054ba4fc68af032101d9db0..08bc61fcc0b56aa5ac252de77a73a84fbfab91e3 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.internal.pcap.core.trace;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.Closeable;
 import java.io.IOException;
 import java.nio.ByteBuffer;
@@ -21,7 +23,6 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.TreeMap;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.pcap.core.packet.BadPacketException;
 import org.eclipse.tracecompass.internal.pcap.core.protocol.pcap.PcapPacket;
@@ -84,9 +85,7 @@ public class PcapFile implements Closeable {
         }
 
         // File is not empty. Try to open.
-        @SuppressWarnings("null")
-        @NonNull SeekableByteChannel channel = Files.newByteChannel(fPcapFilePath);
-        fFileChannel = channel;
+        fFileChannel = checkNotNull(Files.newByteChannel(fPcapFilePath));
 
         // Parse the global header.
         // Read the magic number (4 bytes) from the input stream
@@ -97,26 +96,21 @@ public class PcapFile implements Closeable {
         globalHeader.flip();
         int magicNumber = globalHeader.getInt();
 
-        @SuppressWarnings("null")
-        @NonNull ByteOrder be = ByteOrder.BIG_ENDIAN;
-        @SuppressWarnings("null")
-        @NonNull ByteOrder le = ByteOrder.LITTLE_ENDIAN;
-
         switch (magicNumber) {
         case PcapFileValues.MAGIC_BIG_ENDIAN_MICRO: // file is big endian
-            fByteOrder = be;
+            fByteOrder = checkNotNull(ByteOrder.BIG_ENDIAN);
             fTimestampPrecision = PcapTimestampScale.MICROSECOND;
             break;
         case PcapFileValues.MAGIC_LITTLE_ENDIAN_MICRO: // file is little endian
-            fByteOrder = le;
+            fByteOrder = checkNotNull(ByteOrder.LITTLE_ENDIAN);
             fTimestampPrecision = PcapTimestampScale.MICROSECOND;
             break;
         case PcapFileValues.MAGIC_BIG_ENDIAN_NANO: // file is big endian
-            fByteOrder = be;
+            fByteOrder = checkNotNull(ByteOrder.BIG_ENDIAN);
             fTimestampPrecision = PcapTimestampScale.NANOSECOND;
             break;
         case PcapFileValues.MAGIC_LITTLE_ENDIAN_NANO: // file is little endian
-            fByteOrder = le;
+            fByteOrder = checkNotNull(ByteOrder.LITTLE_ENDIAN);
             fTimestampPrecision = PcapTimestampScale.NANOSECOND;
             break;
         default:
index c47d706618fc49f99aa9d7681752b4b3745215b8..5899c23cda4fd230773f987ba399c7ab62b85001 100644 (file)
 
 package org.eclipse.tracecompass.internal.pcap.core.util;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.pcap.core.protocol.ethernet2.EthernetIIValues;
 
 /**
@@ -26,8 +27,7 @@ import org.eclipse.tracecompass.internal.pcap.core.protocol.ethernet2.EthernetII
  */
 public final class ConversionHelper {
 
-    @SuppressWarnings("null")
-    private static final @NonNull char[] HEX_ARRAY = "0123456789abcdef".toCharArray(); //$NON-NLS-1$
+    private static final char[] HEX_ARRAY = checkNotNull("0123456789abcdef".toCharArray()); //$NON-NLS-1$
     private static final String EMPTY_STRING = ""; //$NON-NLS-1$
     private static final String DEFAULT_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$
     private static final DateFormat DATE_FORMATTER = new SimpleDateFormat(DEFAULT_TIME_PATTERN);
index 4e1a389f670c24c965357c047fd4864e7722ee29..aeba0fb2bdb6ff8ed906cdfd63d539a00f3b45bc 100644 (file)
@@ -21,5 +21,6 @@
    <feature url="features/org.eclipse.tracecompass.rcp_0.0.0.qualifier.jar" id="org.eclipse.tracecompass.rcp" version="0.0.0"/>
    <feature url="features/org.eclipse.tracecompass.rcp.branding.feature_0.0.0.qualifier.jar" id="org.eclipse.tracecompass.rcp.branding.feature" version="0.0.0"/>
    <feature url="features/org.eclipse.tracecompass.testing_0.0.0.qualifier.jar" id="org.eclipse.tracecompass.testing" version="0.0.0"/>
+   <bundle id="org.eclipse.tracecompass.common.core" version="0.1.0.qualifier"/>
    <category-def name="Trace Compass" label="Trace Compass Main Features"/>
 </site>
index abb58a8584701e76ccd51d06efc67395a9d9a69f..2f0b01c10f95060f500ea1715fda5c13bd9e1852 100644 (file)
@@ -9,6 +9,7 @@ Bundle-Activator: org.eclipse.tracecompass.internal.tmf.analysis.xml.core.Activa
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Bundle-ActivationPolicy: lazy
 Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core
 Export-Package: org.eclipse.tracecompass.internal.tmf.analysis.xml.core;x-friends:="org.eclipse.tracecompass.tmf.analysis.xml.core.tests",
  org.eclipse.tracecompass.tmf.analysis.xml.core.model,
index db621edd533fa8a4f46a55f6367f2762b35b603b..219a7a7577803f811f756b40e99c14c8ae247309 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.tmf.analysis.xml.core.model;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNull;
@@ -146,8 +148,7 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue {
         /*
          * Stack Actions : allow to define a stack with PUSH/POP/PEEK methods
          */
-        @SuppressWarnings("null")
-        @NonNull String stack = node.getAttribute(TmfXmlStrings.ATTRIBUTE_STACK);
+        String stack = checkNotNull(node.getAttribute(TmfXmlStrings.ATTRIBUTE_STACK));
         fStackType = ValueTypeStack.getTypeFromString(stack);
     }
 
index cc0ad19df2aa4804b83584028948f2043d24417c..708569d56563cea416678e5913f766cb5dfa9598 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.tmf.analysis.xml.core.model.readonly;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.Collections;
 import java.util.List;
 
@@ -63,7 +65,7 @@ public class TmfXmlReadOnlyStateValue extends TmfXmlStateValue {
      */
     public TmfXmlReadOnlyStateValue(TmfXmlReadOnlyModelFactory modelFactory, Element node,
             IXmlStateSystemContainer container, String eventField) {
-        super(modelFactory, node, container, Collections.EMPTY_LIST, eventField);
+        super(modelFactory, node, container, checkNotNull(Collections.EMPTY_LIST), eventField);
     }
 
 }
index 57664637ed6e48254ded80efbda73a7de58e2734..6ef0198eba99aa3d0f2197ad6efd1979fc959514 100644 (file)
@@ -10,6 +10,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Bundle-ActivationPolicy: lazy
 Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core,
  org.eclipse.tracecompass.tmf.ui,
  org.eclipse.tracecompass.tmf.analysis.xml.core
index 1b6d42d19322173eba81386acab8cea1d954ee7c..5f836f44d10e26e160f49c74d8d70eeaad12a388 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.xychart;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -21,7 +23,6 @@ import java.util.regex.Pattern;
 
 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.swt.widgets.Composite;
 import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.Activator;
@@ -61,8 +62,7 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
     /** Timeout between updates in the updateData thread */
     private static final long BUILD_UPDATE_TIMEOUT = 500;
 
-    @SuppressWarnings("null")
-    private static final @NonNull Pattern WILDCARD_PATTERN = Pattern.compile("\\*"); //$NON-NLS-1$
+    private static final Pattern WILDCARD_PATTERN = checkNotNull(Pattern.compile("\\*")); //$NON-NLS-1$
 
     private final ITmfXmlModelFactory fFactory = TmfXmlReadOnlyModelFactory.getInstance();
     private final Map<Integer, SeriesData> fSeriesData = new HashMap<>();
@@ -188,8 +188,7 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer {
         public List<Integer> getQuarks() {
             /* Get the list of quarks to process with this path */
             String[] paths = fPath.split(SPLIT_STRING);
-            @SuppressWarnings("null")
-            @NonNull List<Integer> quarks = Collections.singletonList(IXmlStateSystemContainer.ROOT_QUARK);
+            List<Integer> quarks = checkNotNull(Collections.singletonList(IXmlStateSystemContainer.ROOT_QUARK));
 
             try {
                 for (String path : paths) {
index a182131210cae8cd24da0a8c9768b4e873a70b1a..68a38298695facd1f0976b8dd5291267c626f976 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.tmf.analysis.xml.ui.module;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.File;
 import java.util.Collections;
 import java.util.List;
@@ -74,9 +76,7 @@ public class TmfAnalysisModuleHelperXml implements IAnalysisModuleHelper {
          * The attribute ID cannot be null because the XML has been validated
          * and it is mandatory
          */
-        @SuppressWarnings("null")
-        @NonNull String id = fSourceElement.getAttribute(TmfXmlStrings.ID);
-        return id;
+        return checkNotNull(fSourceElement.getAttribute(TmfXmlStrings.ID));
     }
 
     @Override
index 1784f17c2328ef4520ccbae888367b2cc600b0b2..d904a5d28cf3dbb28715e4f398eee92273c782ec 100644 (file)
@@ -11,6 +11,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Require-Bundle: org.junit;bundle-version="4.0.0",
  org.eclipse.core.runtime,
  org.eclipse.core.resources,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core;bundle-version="0.1.0",
  org.eclipse.test.performance
 Export-Package: org.eclipse.tracecompass.tmf.core.tests,
@@ -19,4 +20,4 @@ Export-Package: org.eclipse.tracecompass.tmf.core.tests,
  org.eclipse.tracecompass.tmf.tests.stubs.trace,
  org.eclipse.tracecompass.tmf.tests.stubs.trace.xml
 Import-Package: com.google.common.collect,
- com.google.common.primitives;version="15.0.0"
+ com.google.common.primitives
index 1f4b962e73603c2dd226b1c3cf1103a84781f368..362740eca84711d47ba53cea4feb88dcb5562d89 100644 (file)
@@ -13,6 +13,8 @@
 
 package org.eclipse.tracecompass.tmf.tests.stubs.analysis;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.Collections;
 
 import org.eclipse.core.runtime.Platform;
@@ -64,9 +66,7 @@ public class AnalysisModuleTestHelper implements IAnalysisModuleHelper {
 
     @Override
     public String getName() {
-        @SuppressWarnings("null")
-        @NonNull String name = fModule.name();
-        return name;
+        return checkNotNull(fModule.name());
     }
 
     @Override
index a21836ea3468885a05aee0af8d165e7b3a415941..2d4ca22f12e51e1f9c42f29758db396a1bdc92f9 100644 (file)
@@ -10,6 +10,7 @@ Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.core.resources,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.statesystem.core;visibility:=reexport
 Export-Package: org.eclipse.tracecompass.internal.tmf.core;x-friends:="org.eclipse.tracecompass.tmf.core.tests,org.eclipse.tracecompass.tmf.ui.swtbot.tests",
  org.eclipse.tracecompass.internal.tmf.core.analysis;x-friends:="org.eclipse.tracecompass.tmf.core.tests",
index 37c72f3010f925acdd2d774f9d3c4f758830d467..82ddbb7776813166bec6e48c06d1cde9ea49a1ce 100644 (file)
 
 package org.eclipse.tracecompass.internal.tmf.core.analysis;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.Platform;
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleSource;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisModuleHelperConfigElement;
@@ -88,9 +89,7 @@ public final class TmfAnalysisModuleSourceConfigElement implements IAnalysisModu
                 typeElements.add(element);
             }
         }
-        @SuppressWarnings("null")
-        @NonNull IConfigurationElement[] typeElems = typeElements.toArray(new IConfigurationElement[typeElements.size()]);
-        return typeElems;
+        return checkNotNull(typeElements.toArray(new IConfigurationElement[typeElements.size()]));
     }
 
     /**
index 461c6e12e6c9eb019fc9dff598eaee071f545bfb..ee048bdfc043c8565e05efd9da0ebcbc29ceb6e2 100644 (file)
@@ -13,6 +13,8 @@
 
 package org.eclipse.tracecompass.internal.tmf.core.parsers.custom;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNull;
@@ -101,8 +103,6 @@ public class CustomEventAspects {
                 builder.add(new CustomEventFieldAspect(name, i));
             }
         }
-        @SuppressWarnings("null")
-        @NonNull Iterable<ITmfEventAspect> ret = builder.build();
-        return ret;
+        return checkNotNull(builder.build());
     }
 }
index 264e3f1b404be95c56649de7fef2adc49d267960..c85f589926cac683357a7f14b23263dee191c589 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.tmf.core.analysis;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -26,10 +28,10 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.osgi.util.NLS;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel;
 import org.eclipse.tracecompass.tmf.core.component.TmfComponent;
@@ -265,9 +267,7 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
      * @return An iterable list of analysis this analyzes depends on.
      */
     protected Iterable<IAnalysisModule> getDependentAnalyses() {
-        @SuppressWarnings("null")
-        @NonNull Set<IAnalysisModule> emptySet = Collections.EMPTY_SET;
-        return emptySet;
+        return checkNotNull(Collections.EMPTY_LIST);
     }
 
     private void execute(final ITmfTrace trace) {
@@ -299,8 +299,7 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
         /*
          * Actual analysis will be run on a separate thread
          */
-        @SuppressWarnings("null")
-        @NonNull String jobName = NLS.bind(Messages.TmfAbstractAnalysisModule_RunningAnalysis, getName());
+        String jobName = checkNotNull(NLS.bind(Messages.TmfAbstractAnalysisModule_RunningAnalysis, getName()));
         fJob = new Job(jobName) {
             @Override
             protected @Nullable IStatus run(final @Nullable IProgressMonitor monitor) {
@@ -351,9 +350,7 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
             execute(trace);
         }
 
-        @SuppressWarnings("null")
-        @NonNull IStatus status = Status.OK_STATUS;
-        return status;
+        return checkNotNull(Status.OK_STATUS);
     }
 
     @Override
@@ -436,9 +433,9 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
      * @return Full help text for the module
      */
     protected String getFullHelpText() {
-        @SuppressWarnings("null")
-        @NonNull String text = NLS.bind(Messages.TmfAbstractAnalysisModule_AnalysisModule, getName());
-        return text;
+        return NonNullUtils.nullToEmptyString(NLS.bind(
+                Messages.TmfAbstractAnalysisModule_AnalysisModule,
+                getName()));
     }
 
     /**
@@ -450,9 +447,9 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
      * @return Short help text describing the module
      */
     protected String getShortHelpText(ITmfTrace trace) {
-        @SuppressWarnings("null")
-        @NonNull String text = NLS.bind(Messages.TmfAbstractAnalysisModule_AnalysisForTrace, getName(), trace.getName());
-        return text;
+        return NonNullUtils.nullToEmptyString(NLS.bind(
+                Messages.TmfAbstractAnalysisModule_AnalysisForTrace,
+                getName(), trace.getName()));
     }
 
     /**
@@ -480,9 +477,7 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
                 }
             }
         }
-        @SuppressWarnings("null")
-        @NonNull String helpText = builder.toString();
-        return helpText;
+        return checkNotNull(builder.toString());
     }
 
     @Override
@@ -501,8 +496,6 @@ public abstract class TmfAbstractAnalysisModule extends TmfComponent implements
 
     @Override
     public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() {
-        @SuppressWarnings("null")
-        @NonNull Iterable<TmfAnalysisRequirement> emptySet = Collections.EMPTY_SET;
-        return emptySet;
+        return checkNotNull(Collections.EMPTY_SET);
     }
 }
index 96fe0e1820aa93a2b72a8ca1abe25032f27ab770..72ef5f91258fd21eccbc3518c3871ea825131af0 100644 (file)
 
 package org.eclipse.tracecompass.tmf.core.analysis;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
 import org.eclipse.tracecompass.internal.tmf.core.analysis.TmfAnalysisModuleSources;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 
+import com.google.common.collect.ImmutableMap;
+
 /**
  * Manages the available analysis helpers from different sources and their
  * parameter providers.
@@ -116,9 +118,7 @@ public class TmfAnalysisManager {
                 }
             }
         }
-        @SuppressWarnings("null")
-        @NonNull Map<String, IAnalysisModuleHelper> map = Collections.unmodifiableMap(fAnalysisModules);
-        return map;
+        return checkNotNull(ImmutableMap.copyOf(fAnalysisModules));
     }
 
     /**
@@ -138,9 +138,7 @@ public class TmfAnalysisManager {
                 map.put(module.getId(), module);
             }
         }
-        @SuppressWarnings("null")
-        @NonNull Map<String, IAnalysisModuleHelper> retMap = Collections.unmodifiableMap(map);
-        return retMap;
+        return checkNotNull(ImmutableMap.copyOf(map));
     }
 
     /**
index bfea564e29fe6f50290f61ac2b421da273fbc4c8..84f163fbac73ea222ac5e3f72b68105ee13c5c2a 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Timer;
 import java.util.TimerTask;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.internal.tmf.core.TmfCoreTracer;
 import org.eclipse.tracecompass.internal.tmf.core.component.TmfEventThread;
 import org.eclipse.tracecompass.internal.tmf.core.component.TmfProviderManager;
@@ -563,10 +564,9 @@ public abstract class TmfEventProvider extends TmfComponent implements ITmfEvent
         return null;
     }
 
-    @SuppressWarnings("null")
     @Override
     public ITmfEventProvider getChild(int index) {
-        return fChildren.get(index);
+        return NonNullUtils.checkNotNull(fChildren.get(index));
     }
 
     @Override
index 6c197db63313da92eef2e7fd746e525ebf85929f..202404d88e52590b0b23704f77892b159f832c94 100644 (file)
 
 package org.eclipse.tracecompass.tmf.core.event;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.Collection;
+import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
@@ -42,7 +45,7 @@ public class TmfEventField implements ITmfEventField {
 
     private final @NonNull String fName;
     private final @Nullable Object fValue;
-    private final @NonNull ImmutableMap<String, ITmfEventField> fFields;
+    private final @NonNull Map<String, ITmfEventField> fFields;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -60,7 +63,6 @@ public class TmfEventField implements ITmfEventField {
      * @throws IllegalArgumentException
      *             If 'name' is null, or if 'fields' has duplicate field names.
      */
-    @SuppressWarnings("null") /* ImmutableMap methods do not return @NonNull */
     public TmfEventField(String name, @Nullable Object value, @Nullable ITmfEventField[] fields) {
         if (name == null) {
             throw new IllegalArgumentException();
@@ -69,7 +71,7 @@ public class TmfEventField implements ITmfEventField {
         fValue = value;
 
         if (fields == null) {
-            fFields = ImmutableMap.of();
+            fFields = checkNotNull(ImmutableMap.<String, ITmfEventField> of());
         } else {
             /* Java 8 streams will make this even more simple! */
             ImmutableMap.Builder<String, ITmfEventField> mapBuilder = new ImmutableMap.Builder<>();
@@ -77,7 +79,7 @@ public class TmfEventField implements ITmfEventField {
                 final String curName = field.getName();
                 mapBuilder.put(curName, field);
             }
-            fFields = mapBuilder.build();
+            fFields = checkNotNull(mapBuilder.build());
         }
     }
 
index 6fb774743c50851bbf6d4776628b61e1a7e92931..2910e7db678864278982ed94562cb59c6ee225c3 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.tmf.core.event.aspect;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.osgi.util.NLS;
@@ -74,10 +76,7 @@ public class TmfStateSystemAspect implements ITmfEventAspect {
     public String resolve(ITmfEvent event) {
         try {
             ITmfStateValue value = fSS.querySingleState(event.getTimestamp().getValue(), fAttribute).getStateValue();
-
-            @SuppressWarnings("null")
-            @NonNull String ret = value.toString();
-            return ret;
+            return checkNotNull(value.toString());
         } catch (AttributeNotFoundException | StateSystemDisposedException e) {
             return EMPTY_STRING;
         }
index a19364127bbf6cf6975173398f9968f4ae9e89cf..a78bd8803b610d3453e8c49c8ba8b79b8539260a 100644 (file)
@@ -12,7 +12,8 @@
 
 package org.eclipse.tracecompass.tmf.core.event.matching;
 
-import org.eclipse.jdt.annotation.NonNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
@@ -33,8 +34,7 @@ import com.google.common.hash.Hashing;
 @NonNullByDefault
 public class TcpEventKey implements IEventMatchingKey {
 
-    @SuppressWarnings("null")
-    private static final @NonNull HashFunction HF = Hashing.goodFastHash(32);
+    private static final HashFunction HF = checkNotNull(Hashing.goodFastHash(32));
     private final long fSeq;
     private final long fAckseq;
     private final long fFlags;
index ec84d4782a9cd101d6d2cd5f5af831203a9b4eb4..9a087a341f7a14261043ecaf35feb3bf4108783a 100644 (file)
@@ -13,6 +13,8 @@
 
 package org.eclipse.tracecompass.tmf.core.statesystem;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
@@ -21,7 +23,6 @@ import java.util.concurrent.CountDownLatch;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.tmf.core.statesystem.backends.partial.PartialHistoryBackend;
@@ -485,9 +486,7 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
             this.sci = sp;
 
             // sci.getTrace() will eventually return a @NonNull
-            @SuppressWarnings("null")
-            @NonNull ITmfTrace tr = sci.getTrace();
-            trace = tr;
+            trace = checkNotNull(sci.getTrace());
 
         }
 
@@ -557,9 +556,7 @@ public abstract class TmfStateSystemAnalysisModule extends TmfAbstractAnalysisMo
 
     @Override
     public Iterable<ITmfStateSystem> getStateSystems() {
-        @SuppressWarnings("null")
-        @NonNull Iterable<ITmfStateSystem> ret = Collections.singleton((ITmfStateSystem) fStateSystem);
-        return ret;
+        return checkNotNull(Collections.<ITmfStateSystem> singleton(fStateSystem));
     }
 
     /**
index f3cebbde705acce7118d1ca8f321a17a980b21a7..2993db25aecb52ff29f9379c8fe5d1edafa3f60c 100644 (file)
@@ -16,6 +16,8 @@
 
 package org.eclipse.tracecompass.tmf.core.trace;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.File;
 import java.util.Collection;
 import java.util.Collections;
@@ -97,13 +99,12 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
     /**
      * Basic aspects that should be valid for all trace types.
      */
-    @SuppressWarnings("null")
     public static final @NonNull Collection<ITmfEventAspect> BASE_ASPECTS =
-            ImmutableList.of(
+            checkNotNull(ImmutableList.of(
                     ITmfEventAspect.BaseAspects.TIMESTAMP,
                     ITmfEventAspect.BaseAspects.EVENT_TYPE,
                     ITmfEventAspect.BaseAspects.CONTENTS
-                    );
+                    ));
 
     // ------------------------------------------------------------------------
     // Instance attributes
@@ -302,8 +303,7 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
     protected IStatus executeAnalysis() {
         MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null);
 
-        @SuppressWarnings("null")
-        @NonNull Class<? extends TmfTrace> className = this.getClass();
+        Class<? extends TmfTrace> className = checkNotNull(this.getClass());
         Map<String, IAnalysisModuleHelper> modules = TmfAnalysisManager.getAnalysisModules(className);
         for (IAnalysisModuleHelper helper : modules.values()) {
             try {
index 78a75f37d5c29aaec11a316b7168c9367066eae2..9e6c680690d6fe861ceca0fceede1fdf0f476b82 100644 (file)
@@ -14,6 +14,8 @@
 
 package org.eclipse.tracecompass.tmf.core.trace;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.File;
 import java.net.URISyntaxException;
 import java.util.Collections;
@@ -127,8 +129,7 @@ public final class TmfTraceManager {
     /**
      * Gets the filter applied to the current trace
      *
-     * @return
-     *          a filter, or <code>null</code>
+     * @return a filter, or <code>null</code>
      * @since 2.2
      */
     public synchronized ITmfFilter getCurrentFilter() {
@@ -226,9 +227,7 @@ public final class TmfTraceManager {
      */
     public static @NonNull Set<ITmfTrace> getTraceSetWithExperiment(ITmfTrace trace) {
         if (trace == null) {
-            @SuppressWarnings("null")
-            @NonNull Set<ITmfTrace> emptySet = Collections.EMPTY_SET;
-            return emptySet;
+            return checkNotNull(Collections.EMPTY_SET);
         }
         if (trace instanceof TmfExperiment) {
             TmfExperiment exp = (TmfExperiment) trace;
@@ -237,9 +236,7 @@ public final class TmfTraceManager {
             alltraces.add(exp);
             return alltraces;
         }
-        @SuppressWarnings("null")
-        @NonNull Set<ITmfTrace> singleton = Collections.singleton(trace);
-        return singleton;
+        return checkNotNull(Collections.singleton(trace));
     }
 
     /**
@@ -327,7 +324,6 @@ public final class TmfTraceManager {
         fCurrentTrace = trace;
     }
 
-
     /**
      * Handler for the TmfTraceSelectedSignal.
      *
@@ -405,8 +401,8 @@ public final class TmfTraceManager {
     /**
      * Signal handler for the TmfRangeSynchSignal signal.
      *
-     * The current window time range of *all* valid traces will be updated
-     * to the new requested times.
+     * The current window time range of *all* valid traces will be updated to
+     * the new requested times.
      *
      * @param signal
      *            The incoming signal
index cbb971342172a3fe5aa6570fd1f6c461a1348e74..2f399a53d17209c5a0e62c747e876e2121ff55a4 100644 (file)
@@ -13,6 +13,8 @@
 
 package org.eclipse.tracecompass.tmf.core.trace.text;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -64,9 +66,7 @@ public class TextTraceEventContent implements ITmfEventField {
     private TextTraceEventContent(@NonNull String fieldName) {
         fName = fieldName;
         fValue = null;
-        @SuppressWarnings("null")
-        @NonNull List<TextTraceEventContent> fields = Collections.EMPTY_LIST;
-        fFields = fields;
+        fFields = checkNotNull(Collections.EMPTY_LIST);
     }
 
     // ------------------------------------------------------------------------
index 418c12b63c383d21d5d4d40c8e7c4e8c6c351d47..4c2a555cbf68b0b74186929969a83476320d38e6 100644 (file)
@@ -10,6 +10,7 @@ Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.core.resources,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.ctf.core;bundle-version="0.1.0",
  org.eclipse.tracecompass.tmf.core;bundle-version="0.1.0"
 Export-Package: org.eclipse.tracecompass.internal.tmf.ctf.core;x-internal:=true,
index 2e28ce22ccc6efe5a537153aef77b962190ca3fa..5cc679ba496163c6a4c5d0b9b06db9952e64b3fb 100644 (file)
@@ -14,6 +14,8 @@
 
 package org.eclipse.tracecompass.tmf.ctf.core.trace;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
@@ -92,15 +94,14 @@ public class CtfTmfTrace extends TmfTrace
     /**
      * Event aspects available for all CTF traces
      */
-    @SuppressWarnings("null")
     private static final @NonNull Collection<ITmfEventAspect> CTF_ASPECTS =
-            ImmutableList.of(
+            checkNotNull(ImmutableList.of(
                     ITmfEventAspect.BaseAspects.TIMESTAMP,
                     new CtfChannelAspect(),
                     new CtfCpuAspect(),
                     ITmfEventAspect.BaseAspects.EVENT_TYPE,
                     ITmfEventAspect.BaseAspects.CONTENTS
-                    );
+                    ));
 
     /**
      * The Ctf clock unique identifier field
index 518c5ceb69321a79b9f8f8eb2467ab197b2715c6..8a8538fa7da88c5e916c4db66554bf81b5c45637 100644 (file)
@@ -10,6 +10,7 @@ Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.core.resources,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core;bundle-version="0.1.0",
  org.eclipse.tracecompass.pcap.core;bundle-version="0.1.0"
 Export-Package: org.eclipse.tracecompass.internal.tmf.pcap.core;x-internal:=true,
index 3dc2b6e7a3b6755f5a61eaa471353fe4ab64440b..8e9c1fc16f2e4e30b3c980bfb40f2300869ff584 100644 (file)
 
 package org.eclipse.tracecompass.internal.tmf.pcap.core.event;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.List;
 import java.util.Map;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
 import org.eclipse.tracecompass.internal.pcap.core.protocol.PcapProtocol;
@@ -210,9 +210,7 @@ public class PcapEvent extends TmfEvent {
         }
 
         if (packet == null) {
-            @SuppressWarnings("null")
-            @NonNull List<TmfPcapProtocol> emptyList = Collections.EMPTY_LIST;
-            fProtocols = emptyList;
+            fProtocols = checkNotNull(Collections.EMPTY_LIST);
             return fProtocols;
         }
         // Go through all the packets and add them to list.
@@ -224,10 +222,8 @@ public class PcapEvent extends TmfEvent {
             }
         }
 
-        @SuppressWarnings("null")
-        @NonNull ImmutableList<TmfPcapProtocol> immutableList = builder.build();
-        fProtocols = immutableList;
-        return immutableList;
+        fProtocols = checkNotNull(builder.build());
+        return fProtocols;
     }
 
     /**
index 0feefb8bbbd19500bdb7eff2b9c09356307b4e1b..8c040d7584d2e06c4b70ba6f85d3af36b21c0436 100644 (file)
@@ -12,8 +12,8 @@
 
 package org.eclipse.tracecompass.internal.tmf.pcap.core.event;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
 
@@ -24,13 +24,10 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
  */
 public class PcapEventType extends TmfEventType {
 
-    private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
     /**
      * The default Pcap Type ID for a PcapEvent
      */
-    @SuppressWarnings("null")
-    public static final @NonNull String DEFAULT_PCAP_TYPE_ID = Messages.PcapEventType_DefaultTypeID == null ? EMPTY_STRING : Messages.PcapEventType_DefaultTypeID;
+    public static final String DEFAULT_PCAP_TYPE_ID = NonNullUtils.nullToEmptyString(Messages.PcapEventType_DefaultTypeID);
 
     /**
      * Default constructor
index c71fb30fa5ae56c9253dbe22d9cc27f88d61a60d..75619c80e5b9036c027ab362b6ecc6275d4b8be2 100644 (file)
@@ -13,7 +13,8 @@
 
 package org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect;
 
-import org.eclipse.jdt.annotation.NonNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.tmf.pcap.core.event.PcapEvent;
 import org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol;
@@ -45,9 +46,7 @@ public class PcapProtocolAspect implements ITmfEventAspect {
         PcapEvent pcapEvent = (PcapEvent) event;
         TmfPcapProtocol protocol = pcapEvent.getMostEncapsulatedProtocol();
 
-        @SuppressWarnings("null")
-        @NonNull String proto = protocol.getShortName().toUpperCase();
-        return proto;
+        return checkNotNull(protocol.getShortName().toUpperCase());
     }
 
     @Override
index c904c0297ca2c9612df9a804e0fbdfbf9766e8cb..72f6371351dcf9e5145f0dd4c1e7b3b2811d55fd 100644 (file)
 
 package org.eclipse.tracecompass.internal.tmf.pcap.core.trace;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.IOException;
 import java.nio.channels.ClosedChannelException;
-import java.nio.file.FileSystems;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 
 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.internal.pcap.core.packet.BadPacketException;
 import org.eclipse.tracecompass.internal.pcap.core.protocol.pcap.PcapPacket;
@@ -62,22 +64,20 @@ import com.google.common.collect.ImmutableMap;
  */
 public class PcapTrace extends TmfTrace implements ITmfEventParser, ITmfTraceProperties, AutoCloseable {
 
-    @SuppressWarnings("null")
-    private static final @NonNull Collection<ITmfEventAspect> PCAP_ASPECTS = ImmutableList.of(
-            ITmfEventAspect.BaseAspects.TIMESTAMP,
-            new PcapSourceAspect(),
-            new PcapDestinationAspect(),
-            new PcapReferenceAspect(),
-            new PcapProtocolAspect(),
-            ITmfEventAspect.BaseAspects.CONTENTS
-            );
+    private static final Collection<ITmfEventAspect> PCAP_ASPECTS =
+            checkNotNull(ImmutableList.of(
+                    ITmfEventAspect.BaseAspects.TIMESTAMP,
+                    new PcapSourceAspect(),
+                    new PcapDestinationAspect(),
+                    new PcapReferenceAspect(),
+                    new PcapProtocolAspect(),
+                    ITmfEventAspect.BaseAspects.CONTENTS
+                    ));
 
-    @SuppressWarnings("null")
-    private static final @NonNull Map<String, String> EMPTY_MAP = ImmutableMap.of();
     private static final String EMPTY_STRING = ""; //$NON-NLS-1$
     private static final int CONFIDENCE = 50;
     private @Nullable PcapFile fPcapFile;
-    private @Nullable ImmutableMap<String, String> fTraceProperties = null;
+    private @Nullable Map<String, String> fTraceProperties = null;
 
     @Override
     public synchronized ITmfLocation getCurrentLocation() {
@@ -114,8 +114,7 @@ public class PcapTrace extends TmfTrace implements ITmfEventParser, ITmfTracePro
         if (path == null) {
             throw new TmfTraceException("No path has been specified."); //$NON-NLS-1$
         }
-        @SuppressWarnings("null")
-        @NonNull Path filePath = FileSystems.getDefault().getPath(path);
+        Path filePath = checkNotNull(Paths.get(path));
         try {
             fPcapFile = new PcapFile(filePath);
         } catch (IOException | BadPcapFileException e) {
@@ -211,8 +210,7 @@ public class PcapTrace extends TmfTrace implements ITmfEventParser, ITmfTracePro
         if (path == null) {
             return new Status(IStatus.ERROR, Activator.PLUGIN_ID, EMPTY_STRING);
         }
-        @SuppressWarnings("null")
-        @NonNull Path filePath = FileSystems.getDefault().getPath(path);
+        Path filePath = checkNotNull(Paths.get(path));
         try (PcapFile file = new PcapFile(filePath)) {
         } catch (IOException | BadPcapFileException e) {
             return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString());
@@ -244,22 +242,20 @@ public class PcapTrace extends TmfTrace implements ITmfEventParser, ITmfTracePro
     public synchronized Map<String, String> getTraceProperties() {
         PcapFile pcap = fPcapFile;
         if (pcap == null) {
-            return EMPTY_MAP;
+            return checkNotNull(Collections.<String, String> emptyMap());
         }
 
-        ImmutableMap<String, String> properties = fTraceProperties;
+        Map<String, String> properties = fTraceProperties;
         if (properties == null) {
-            @SuppressWarnings("null")
-            @NonNull ImmutableMap<String, String> newProperties = ImmutableMap.<String, String> builder()
-                    .put(Messages.PcapTrace_Version, String.format("%d%c%d", pcap.getMajorVersion(), '.', pcap.getMinorVersion())) //$NON-NLS-1$
-                    .put(Messages.PcapTrace_TimeZoneCorrection, pcap.getTimeZoneCorrection() + " s") //$NON-NLS-1$
-                    .put(Messages.PcapTrace_TimestampAccuracy, String.valueOf(pcap.getTimeAccuracy()))
-                    .put(Messages.PcapTrace_MaxSnapLength, pcap.getSnapLength() + " bytes") //$NON-NLS-1$
-                    .put(Messages.PcapTrace_LinkLayerHeaderType, LinkTypeHelper.toString((int) pcap.getDataLinkType()) + " (" + pcap.getDataLinkType() + ")") //$NON-NLS-1$ //$NON-NLS-2$
-                    .put(Messages.PcapTrace_FileEndianness, pcap.getByteOrder().toString())
-                    .build();
-            fTraceProperties = newProperties;
-            return newProperties;
+            ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder();
+            builder.put(Messages.PcapTrace_Version, String.format("%d%c%d", pcap.getMajorVersion(), '.', pcap.getMinorVersion())); //$NON-NLS-1$
+            builder.put(Messages.PcapTrace_TimeZoneCorrection, pcap.getTimeZoneCorrection() + " s"); //$NON-NLS-1$
+            builder.put(Messages.PcapTrace_TimestampAccuracy, String.valueOf(pcap.getTimeAccuracy()));
+            builder.put(Messages.PcapTrace_MaxSnapLength, pcap.getSnapLength() + " bytes"); //$NON-NLS-1$
+            builder.put(Messages.PcapTrace_LinkLayerHeaderType, LinkTypeHelper.toString((int) pcap.getDataLinkType()) + " (" + pcap.getDataLinkType() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+            builder.put(Messages.PcapTrace_FileEndianness, pcap.getByteOrder().toString());
+
+            return checkNotNull(builder.build());
 
         }
 
index 6a2d13426fe8a679c9ab977d094e52bbf0d23164..b6463d666e4a92ff1cc8a3fa68caf0b7f96cc26c 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.tracecompass.internal.tmf.pcap.core.util;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -81,8 +83,7 @@ public class PcapEventFactory {
             throw new IllegalArgumentException("The timestamp precision is not valid!"); //$NON-NLS-1$
         }
         Path filePath = pcap.getPath().getFileName();
-        @SuppressWarnings("null") // for .toString()
-        @NonNull String fileName = (filePath == null ? EMPTY_STRING : filePath.toString());
+        @NonNull String fileName = (filePath == null ? EMPTY_STRING : checkNotNull(filePath.toString()));
 
         String dataLink = Messages.PcapEventFactory_LinkType + ':' + LinkTypeHelper.toString((int) pcapPacket.getPcapFile().getDataLinkType());
 
@@ -111,12 +112,8 @@ public class PcapEventFactory {
         while (localPacket != null) {
             subfieldList.clear();
             for (Map.Entry<String, String> entry : localPacket.getFields().entrySet()) {
-
-                @SuppressWarnings("null")
-                @NonNull String key = entry.getKey();
-
-                @SuppressWarnings("null")
-                @NonNull String value = entry.getValue();
+                String key = entry.getKey();
+                String value = entry.getValue();
                 subfieldList.add(new TmfEventField(key, value, null));
             }
             ITmfEventField[] subfieldArray = subfieldList.toArray(new ITmfEventField[subfieldList.size()]);
index e237528407e25e46fd816fadd7553cd166cad5a6..8c649fec4050ec436ce28582ddc72294af7da48f 100644 (file)
@@ -12,6 +12,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.core.resources,
  org.eclipse.ui,
  org.eclipse.ui.ide,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core;bundle-version="0.1.0",
  org.eclipse.tracecompass.tmf.ui;bundle-version="0.1.0",
  org.eclipse.tracecompass.tmf.pcap.core;bundle-version="0.1.0"
index d7f3761e09f97f087fc437be3bdbf5c1725b181b..d67631a9cd631d33236135a539362c5069da6042 100644 (file)
@@ -12,7 +12,8 @@
 
 package org.eclipse.tracecompass.internal.tmf.pcap.ui;
 
-import org.eclipse.jdt.annotation.NonNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.internal.tmf.pcap.ui.stream.StreamListView;
 import org.eclipse.tracecompass.tmf.ui.project.wizards.NewTmfProjectWizard;
@@ -39,12 +40,9 @@ public class NetworkingPerspectiveFactory implements IPerspectiveFactory {
     public static final String ID = "org.eclipse.linuxtools.tmf.pcap.ui.perspective.network"; //$NON-NLS-1$
 
     // Views
-    @SuppressWarnings("null")
-    private static final @NonNull String PROJECT_VIEW_ID = IPageLayout.ID_PROJECT_EXPLORER;
-    @SuppressWarnings("null")
-    private static final @NonNull String PROPERTIES_VIEW_ID = IPageLayout.ID_PROP_SHEET;
-    @SuppressWarnings("null")
-    private static final @NonNull String BOOKMARKS_VIEW_ID = IPageLayout.ID_BOOKMARKS;
+    private static final String PROJECT_VIEW_ID = checkNotNull(IPageLayout.ID_PROJECT_EXPLORER);
+    private static final String PROPERTIES_VIEW_ID = checkNotNull(IPageLayout.ID_PROP_SHEET);
+    private static final String BOOKMARKS_VIEW_ID = checkNotNull(IPageLayout.ID_BOOKMARKS);
     private static final String FILTER_VIEW_ID = FilterView.ID;
     private static final String HISTOGRAM_VIEW_ID = HistogramView.ID;
     private static final String STATISTICS_VIEW_ID = TmfStatisticsView.ID;
index 7fed461c008427ddcd4451388adace9d765fa133..034620980da4d6b7832eb307c4763e5761d36694 100644 (file)
@@ -17,7 +17,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.CTabFolder;
@@ -275,9 +274,10 @@ public class StreamListView extends TmfView {
                 if (tables == null) {
                     return;
                 }
-                for (TmfPcapProtocol p : tables.keySet()) {
-                    @SuppressWarnings("null")
-                    @NonNull TmfPcapProtocol protocol = p;
+                for (TmfPcapProtocol protocol : tables.keySet()) {
+                    if (protocol == null) {
+                        throw new IllegalStateException();
+                    }
                     TmfPacketStreamBuilder builder = analysis.getBuilder(protocol);
                     if (builder != null && !(tables.get(protocol).isDisposed())) {
                         for (TmfPacketStream stream : builder.getStreams()) {
index f41da53a233b921281fb8341e97aad35e60fedfd..20ad171417cb75a1c60262553ea0f401d5ecaae3 100644 (file)
@@ -12,6 +12,7 @@ Require-Bundle: org.eclipse.core.expressions,
  org.eclipse.core.filesystem,
  org.eclipse.core.resources,
  org.eclipse.core.runtime,
+ org.eclipse.tracecompass.common.core,
  org.eclipse.tracecompass.tmf.core;bundle-version="0.1.0",
  org.eclipse.ui,
  org.eclipse.ui.ide,
index 8c831d9aa3500e6e1c0921c06bd860898aa29c70..5d404070236d10d7fe4c8cf599b3d8a82ec351a2 100644 (file)
@@ -13,6 +13,8 @@
 
 package org.eclipse.tracecompass.tmf.ui.editors;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.List;
 
 import org.eclipse.core.resources.IFile;
@@ -371,10 +373,7 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus
                 builder.addAll(traceAspects);
             }
         }
-
-        @SuppressWarnings("null")
-        @NonNull Iterable<ITmfEventAspect> ret = builder.build();
-        return ret;
+        return checkNotNull(builder.build());
     }
 
     /**
index dadf9b2ddba376d6a46e5b16b6c0f782f140faf0..4ad4a9f492ab34e4cc77de95e4a48ded4d677da6 100644 (file)
@@ -17,6 +17,8 @@
 
 package org.eclipse.tracecompass.tmf.ui.viewers.events;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -361,9 +363,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                 builder.add(new TmfEventFieldAspect(fieldName, fieldName));
             }
         }
-        @SuppressWarnings("null")
-        @NonNull Iterable<ITmfEventAspect> ret = builder.build();
-        return ret;
+        return checkNotNull(builder.build());
     }
 
     /**
index 781159675ffe092cde4344baa3edb167524412c6..76bdacb72408375de2e876b66459233e1c391227 100644 (file)
@@ -12,7 +12,8 @@
 
 package org.eclipse.tracecompass.tmf.ui.viewers.events.columns;
 
-import org.eclipse.jdt.annotation.NonNull;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
@@ -88,10 +89,7 @@ public class TmfEventTableColumn {
      * @return The string to display in the column for this event
      */
     public String getItemString(ITmfEvent event) {
-        /* resolve() is NonNull. toString() is not, but should never return null */
-        @SuppressWarnings("null")
-        @NonNull String ret = fAspect.resolve(event).toString();
-        return ret;
+        return checkNotNull(fAspect.resolve(event).toString());
     }
 
     /**
index d4b77e0fe1443af5e09aca96fd4fc6f029cbc025..a42fae4863858b9a4b4621d0284f5294deed3b75 100644 (file)
@@ -16,6 +16,8 @@
 
 package org.eclipse.tracecompass.tmf.ui.views.timegraph;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -1128,9 +1130,7 @@ public abstract class AbstractTimeGraphView extends TmfView {
      * @since 3.0
      */
     protected @NonNull Iterable<ITmfTrace> getTracesToBuild(@NonNull ITmfTrace trace) {
-        @SuppressWarnings("null")
-        @NonNull List<ITmfTrace> list = Arrays.asList(TmfTraceManager.getTraceSet(trace));
-        return list;
+        return checkNotNull(Arrays.asList(TmfTraceManager.getTraceSet(trace)));
     }
 
     /**
This page took 0.067944 seconds and 5 git commands to generate.