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>
import java.io.File;
import java.nio.ByteOrder;
-import java.util.Map;
import java.util.UUID;
import org.eclipse.linuxtools.ctf.core.event.CTFClock;
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.
*/
}
/* 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
}
/**
- * 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();
}
/**
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;
* 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();
/*