PrefixMatcher implements IMatcher { @Override public boolean matches(final CtClass ctClass) { return this.matchesPrefix(ctClass.getName()); } PrefixMatcher(final String... strings);  PrefixMatcher(final List<String> strings); @Override boolean matches(final CtClass ctClass); @Override boolean matches(final CtBehavior ctBehavior); @Override boolean matches(final CtField ctField);  }
@Test public void testClassPrefixMatcher() throws Exception { PrefixMatcher prefixMatcher = new PrefixMatcher("org.gzoltar.examples.Abstract"); CtClass ctClass = pool.get(AbstractClass.class.getCanonicalName()); assertTrue(prefixMatcher.matches(ctClass)); }
@Test public void testMethodPrefixMatcher() throws Exception { PrefixMatcher prefixMatcher = new PrefixMatcher("is"); CtClass ctClass = pool.get(InterfaceClass.class.getCanonicalName()); CtBehavior ctBehavior = ctClass.getDeclaredMethod("isNegative"); assertTrue(prefixMatcher.matches(ctBehavior)); }
@Test public void testFieldPrefixMatcher() throws Exception { PrefixMatcher prefixMatcher = new PrefixMatcher("str"); CtClass ctClass = pool.get(PublicModifiers.class.getCanonicalName()); CtField ctField = ctClass.getField("string"); assertTrue(prefixMatcher.matches(ctField)); }