@Test public void testPublicOrProtectedMethods() throws Exception { MethodModifierMatcher publicMethodsMatcher = new MethodModifierMatcher(AccessFlag.PUBLIC); MethodModifierMatcher protectedMethodsMatcher = new MethodModifierMatcher(AccessFlag.PROTECTED); OrMatcher orMatcher = new OrMatcher(publicMethodsMatcher, protectedMethodsMatcher); CtClass ctClass = pool.get(PublicModifiers.class.getCanonicalName()); CtBehavior ctBehavior = ctClass.getDeclaredMethod("isNegative"); assertTrue(orMatcher.matches(ctBehavior)); ctClass = pool.get(ProtectedModifiers.class.getCanonicalName()); ctBehavior = ctClass.getDeclaredMethod("isNegative"); assertTrue(orMatcher.matches(ctBehavior)); ctClass = pool.get(PrivateModifiers.class.getCanonicalName()); ctBehavior = ctClass.getDeclaredMethod("isNegative"); assertFalse(orMatcher.matches(ctBehavior)); }
@Override public boolean matches(final CtClass ctClass) { for (IMatcher mat : this.matchers) { if (mat.matches(ctClass)) { return true; } } return false; }
OrMatcher implements IMatcher { @Override public boolean matches(final CtClass ctClass) { for (IMatcher mat : this.matchers) { if (mat.matches(ctClass)) { return true; } } return false; } }
OrMatcher implements IMatcher { @Override public boolean matches(final CtClass ctClass) { for (IMatcher mat : this.matchers) { if (mat.matches(ctClass)) { return true; } } return false; } OrMatcher(final IMatcher... matchers); }
OrMatcher implements IMatcher { @Override public boolean matches(final CtClass ctClass) { for (IMatcher mat : this.matchers) { if (mat.matches(ctClass)) { return true; } } return false; } OrMatcher(final IMatcher... matchers); @Override boolean matches(final CtClass ctClass); @Override boolean matches(final CtBehavior ctBehavior); @Override boolean matches(final CtField ctField); }
OrMatcher implements IMatcher { @Override public boolean matches(final CtClass ctClass) { for (IMatcher mat : this.matchers) { if (mat.matches(ctClass)) { return true; } } return false; } OrMatcher(final IMatcher... matchers); @Override boolean matches(final CtClass ctClass); @Override boolean matches(final CtBehavior ctBehavior); @Override boolean matches(final CtField ctField);  }