DirectoryStream implements Iterable<DirectoryEntry> { public DirectoryStream transform(Function<? super DirectoryEntry, DirectoryEntry> function) { return new DirectoryStream(this.verifier, new TransformingNavigableSet(function, entries)); } DirectoryStream(Collection<DirectoryEntry> entries);  DirectoryStream(byte[] verifier, Collection<DirectoryEntry> entries);  DirectoryStream(byte[] verifier, NavigableSet<DirectoryEntry> entries); byte[] getVerifier(); @Override Iterator<DirectoryEntry> iterator(); DirectoryStream tail(long fromCookie); DirectoryStream transform(Function<? super DirectoryEntry, DirectoryEntry> function); final static byte[] ZERO_VERIFIER; }
@Test public void testTransform() { DirectoryStream transformed = stream.transform(d -> new DirectoryEntry(d.getName().toUpperCase(), d.getInode(), d.getStat(), d.getCookie())); assertArrayEquals(stream.getVerifier(), transformed.getVerifier()); for (DirectoryEntry e : transformed) { assertTrue(e.getName().startsWith("FILE")); } }