@Test public void testGetFirst() { final AudioStreamChunk audio = new AudioStreamChunk(BigInteger.ZERO); final VideoStreamChunk video = new VideoStreamChunk(BigInteger.ZERO); video.setPosition(1); ChunkContainer container = createChunk(0, BigInteger.ZERO); container.addChunk(audio); container.addChunk(video); Assert.assertSame(audio, container.getFirst(GUID.GUID_STREAM, AudioStreamChunk.class)); Assert.assertNull(container.getFirst(GUID.GUID_STREAM, VideoStreamChunk.class)); container = createChunk(0, BigInteger.ZERO); container.addChunk(video); container.addChunk(audio); Assert.assertSame(video, container.getFirst(GUID.GUID_STREAM, VideoStreamChunk.class)); Assert.assertNull(container.getFirst(GUID.GUID_STREAM, AudioStreamChunk.class)); }
protected Chunk getFirst(final GUID lookFor, final Class<? extends Chunk> instanceOf) { Chunk result = null; final List<Chunk> list = this.chunkTable.get(lookFor); if (list != null && !list.isEmpty()) { final Chunk chunk = list.get(0); if (instanceOf.isAssignableFrom(chunk.getClass())) { result = chunk; } } return result; }
ChunkContainer extends Chunk { protected Chunk getFirst(final GUID lookFor, final Class<? extends Chunk> instanceOf) { Chunk result = null; final List<Chunk> list = this.chunkTable.get(lookFor); if (list != null && !list.isEmpty()) { final Chunk chunk = list.get(0); if (instanceOf.isAssignableFrom(chunk.getClass())) { result = chunk; } } return result; } }
ChunkContainer extends Chunk { protected Chunk getFirst(final GUID lookFor, final Class<? extends Chunk> instanceOf) { Chunk result = null; final List<Chunk> list = this.chunkTable.get(lookFor); if (list != null && !list.isEmpty()) { final Chunk chunk = list.get(0); if (instanceOf.isAssignableFrom(chunk.getClass())) { result = chunk; } } return result; } ChunkContainer(final GUID chunkGUID, final long pos, final BigInteger length); }
ChunkContainer extends Chunk { protected Chunk getFirst(final GUID lookFor, final Class<? extends Chunk> instanceOf) { Chunk result = null; final List<Chunk> list = this.chunkTable.get(lookFor); if (list != null && !list.isEmpty()) { final Chunk chunk = list.get(0); if (instanceOf.isAssignableFrom(chunk.getClass())) { result = chunk; } } return result; } ChunkContainer(final GUID chunkGUID, final long pos, final BigInteger length); void addChunk(final Chunk toAdd); Collection<Chunk> getChunks(); boolean hasChunkByGUID(final GUID lookFor); @Override String prettyPrint(final String prefix); String prettyPrint(final String prefix, final String containerInfo); }
ChunkContainer extends Chunk { protected Chunk getFirst(final GUID lookFor, final Class<? extends Chunk> instanceOf) { Chunk result = null; final List<Chunk> list = this.chunkTable.get(lookFor); if (list != null && !list.isEmpty()) { final Chunk chunk = list.get(0); if (instanceOf.isAssignableFrom(chunk.getClass())) { result = chunk; } } return result; } ChunkContainer(final GUID chunkGUID, final long pos, final BigInteger length); void addChunk(final Chunk toAdd); Collection<Chunk> getChunks(); boolean hasChunkByGUID(final GUID lookFor); @Override String prettyPrint(final String prefix); String prettyPrint(final String prefix, final String containerInfo);  }