### Question:
Optimizer { static Matcher startsWithCharSeq(Matcher matcher) { if (matcher instanceof SeqMatcher) { List<Matcher> matchers = matcher.<SeqMatcher>as().matchers(); if (matchers.size() >= 2 && matchers.get(0) instanceof StartMatcher && matchers.get(1) instanceof CharSeqMatcher) { List<Matcher> ms = new ArrayList<>(); ms.add(new StartsWithMatcher(matchers.get(1).<CharSeqMatcher>as().pattern())); ms.addAll(matchers.subList(2, matchers.size())); return SeqMatcher.create(ms); } } return matcher; } private  Optimizer();   }### Answer:
@Test public void startsWithCharSeq() { Matcher input = SeqMatcher.create( StartMatcher.INSTANCE, new CharSeqMatcher("ab"), AnyMatcher.INSTANCE ); Matcher expected = SeqMatcher.create( new StartsWithMatcher("ab"), AnyMatcher.INSTANCE ); Assertions.assertEquals(expected, Optimizer.startsWithCharSeq(input)); }