btf: Move the plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.pcap.core / src / org / eclipse / tracecompass / internal / pcap / core / protocol / pcap / PcapPacket.java
index b8120c740382a0feda05690fd86f59fb44c68d8b..be6ae08961efa94dbc239fac63753581e528cce8 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;
     }
@@ -324,17 +323,9 @@ public class PcapPacket extends Packet {
             return false;
         }
         PcapPacket other = (PcapPacket) obj;
-        final Packet child = fChildPacket;
-        if (child != null) {
-            if (!child.equals(other.fChildPacket)) {
-                return false;
-            }
-        } else {
-            if (other.fChildPacket != null) {
-                return false;
-            }
+        if(!NonNullUtils.equalsNullable(fChildPacket, other.fChildPacket)){
+            return false;
         }
-
         if (fIncludedLength != other.fIncludedLength) {
             return false;
         }
@@ -344,17 +335,9 @@ public class PcapPacket extends Packet {
         if (fPacketIndex != other.fPacketIndex) {
             return false;
         }
-        final ByteBuffer payload = fPayload;
-        if (payload != null) {
-            if (!payload.equals(other.fPayload)) {
-                return false;
-            }
-        } else {
-            if (other.fPayload != null) {
-                return false;
-            }
+        if(!NonNullUtils.equalsNullable(fPayload, other.fPayload)) {
+            return false;
         }
-
         if (fTimestamp != other.fTimestamp) {
             return false;
         }
This page took 0.035835 seconds and 5 git commands to generate.