diff options
author | Etienne Bergeron | 2013-12-18 03:18:31 +0000 |
---|---|---|
committer | Matthew Khouzam | 2014-01-02 19:01:25 +0000 |
commit | 55dba6bb8194045a142cc62656a20edae588df09 (patch) | |
tree | a2c20d22dd5c73789b39a26b7e279dd168b8f1e5 | |
parent | ca9ab0c021c75babc5440a816eb5548f51670307 (diff) | |
download | org.eclipse.linuxtools-55dba6bb8194045a142cc62656a20edae588df09.tar.gz org.eclipse.linuxtools-55dba6bb8194045a142cc62656a20edae588df09.tar.xz org.eclipse.linuxtools-55dba6bb8194045a142cc62656a20edae588df09.zip |
ctf: move getStreams to an iterable.
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>
3 files changed, 7 insertions, 20 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java index 04bd2eef52..b69ce43e20 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java +++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java @@ -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; @@ -193,15 +192,6 @@ public class CTFTraceTest { } /** - * 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. */ @Test diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java index 9f6af8c6d0..c97e1b61cc 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java +++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java @@ -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(); } /** diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java index 6110129400..d8e24cd95f 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java +++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java @@ -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(); /* |