class CompositeFileReader implements FileReader {

    @Nullable
    @Override
    public CharStream read(String name) {
        for (FileReader delegate : delegateList) {
            CharStream result = delegate.read(name);
            if (result != null) {
                return result;
            }
        }
        return null;
    }

}

class CompositeFileReaderTest {

    @Test
    public void testRead() throws Exception {

        TestReader r1 = new TestReader("1.proto", "1");
        TestReader r2 = new TestReader("2.proto", "2");
        CompositeFileReader reader = new CompositeFileReader(r1, r2);
        CharStream s1 = reader.read("1.proto");
        CharStream s2 = reader.read("2.proto");
        CharStream s3 = reader.read("3.proto");
        assertNotNull(s1);
        assertNotNull(s2);
        assertNull(s3);
        assertEquals("1", s1.getText(Interval.of(0, 1)));
        assertEquals("2", s2.getText(Interval.of(0, 1)));
    }

}