import org.pcap4j.packet.TcpPacket;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Objects;
mPackets.add(packet);
}
+ /**
+ * Get a list of packets pertaining to this {@code Conversation}.
+ * The returned list is a read-only list.
+ * @return the list of packets pertaining to this {@code Conversation}.
+ */
+ public List<PcapPacket> getPackets() {
+ // Return read-only view to prevent external code from manipulating internal state (preserve invariant).
+ return Collections.unmodifiableList(mPackets);
+ }
+
// =========================================================================================================
// We simply reuse equals and hashCode methods of String.class to be able to use this class as a key
// in a Map.