ctf: move getStreams to an iterable.
authorEtienne Bergeron <etienne.bergeron@gmail.com>
Wed, 18 Dec 2013 03:18:31 +0000 (22:18 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 2 Jan 2014 19:01:25 +0000 (14:01 -0500)
This is an example of how to break the internals access.

Keep separate the "get/set/iterate" over an internals data-structure.

Change-Id: Id79b4eeedd3636de142d3317cbb1b1ae6fe2f50a
Signed-off-by: Etienne Bergeron <etienne.bergeron@gmail.com>
Reviewed-on: https://git.eclipse.org/r/19933
Tested-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com>

org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java

index 04bd2eef528896d7bd072027be8a5c997a03b00f..b69ce43e2093b4df50e655eef180609fcc3d0b42 100644 (file)
@@ -23,7 +23,6 @@ import static org.junit.Assume.assumeTrue;
 
 import java.io.File;
 import java.nio.ByteOrder;
-import java.util.Map;
 import java.util.UUID;
 
 import org.eclipse.linuxtools.ctf.core.event.CTFClock;
@@ -192,15 +191,6 @@ public class CTFTraceTest {
         assertNotNull(result);
     }
 
-    /**
-     * Run the Map<Long, Stream> getStreams() method test.
-     */
-    @Test
-    public void testGetStreams() {
-        Map<Long, Stream> result = fixture.getStreams();
-        assertNotNull(result);
-    }
-
     /**
      * Run the File getTraceDirectory() method test.
      */
index 9f6af8c6d0e20146c990bcdf5560222ac893bce2..c97e1b61cc026e0189db6aa0c3faaf7d23d4a83e 100644 (file)
@@ -200,8 +200,8 @@ public class CTFTrace implements IDefinitionScope {
         }
 
         /* Create their index */
-        for (Map.Entry<Long, Stream> stream : streams.entrySet()) {
-            Set<StreamInput> inputs = stream.getValue().getStreamInputs();
+        for (Stream stream : getStreams()) {
+            Set<StreamInput> inputs = stream.getStreamInputs();
             for (StreamInput s : inputs) {
                 /*
                  * Copy the events
@@ -460,12 +460,12 @@ public class CTFTrace implements IDefinitionScope {
     }
 
     /**
-     * Method getStreams get all the streams in a map format.
+     * Get all the streams as an iterable.
      *
-     * @return Map<Long,Stream> a map of all the streams.
+     * @return Iterable<Stream> an iterable over streams.
      */
-    public Map<Long, Stream> getStreams() {
-        return streams;
+    public Iterable<Stream> getStreams() {
+        return streams.values();
     }
 
     /**
index 6110129400b3f1c5641d509df462414e6800ed78..d8e24cd95fb0e64a9bfdd44de65885585b3fa707 100644 (file)
@@ -14,7 +14,6 @@
 package org.eclipse.linuxtools.ctf.core.trace;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.PriorityQueue;
 import java.util.Set;
@@ -176,12 +175,10 @@ public class CTFTraceReader {
      *             if an error occurs
      */
     private void createStreamInputReaders() throws CTFReaderException {
-        Collection<Stream> streams = this.trace.getStreams().values();
-
         /*
          * For each stream.
          */
-        for (Stream stream : streams) {
+        for (Stream stream : this.trace.getStreams()) {
             Set<StreamInput> streamInputs = stream.getStreamInputs();
 
             /*
This page took 0.028089 seconds and 5 git commands to generate.