/** * Apply an intersection with the given ClassFilter. * @param other the ClassFilter to apply an intersection with * @return this composable pointcut (for call chaining) */ public ComposablePointcut intersection(ClassFilter other) { this.classFilter = ClassFilters.intersection(this.classFilter, other); return this; }
/** * Apply a union with the given ClassFilter. * @param other the ClassFilter to apply a union with * @return this composable pointcut (for call chaining) */ public ComposablePointcut union(ClassFilter other) { this.classFilter = ClassFilters.union(this.classFilter, other); return this; }
/** * Private constructor to share common code between impl-based delegate and reference-based delegate * (cannot use method such as init() to share common code, due the use of final fields). * @param interfaceType static field defining the introduction * @param typePattern type pattern the introduction is restricted to * @param interceptor the delegation advice as {@link IntroductionInterceptor} */ private DeclareParentsAdvisor(Class<?> interfaceType, String typePattern, IntroductionInterceptor interceptor) { this.advice = interceptor; this.introducedInterface = interfaceType; // Excludes methods implemented. ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern); ClassFilter exclusion = (clazz -> !this.introducedInterface.isAssignableFrom(clazz)); this.typePatternClassFilter = ClassFilters.intersection(typePatternFilter, exclusion); }
/** * Apply a union with the given Pointcut. * <p>Note that for a Pointcut union, methods will only match if their * original ClassFilter (from the originating Pointcut) matches as well. * MethodMatchers and ClassFilters from different Pointcuts will never * get interleaved with each other. * @param other the Pointcut to apply a union with * @return this composable pointcut (for call chaining) */ public ComposablePointcut union(Pointcut other) { this.methodMatcher = MethodMatchers.union( this.methodMatcher, this.classFilter, other.getMethodMatcher(), other.getClassFilter()); this.classFilter = ClassFilters.union(this.classFilter, other.getClassFilter()); return this; }
/** * Apply an intersection with the given Pointcut. * @param other the Pointcut to apply an intersection with * @return this composable pointcut (for call chaining) */ public ComposablePointcut intersection(Pointcut other) { this.classFilter = ClassFilters.intersection(this.classFilter, other.getClassFilter()); this.methodMatcher = MethodMatchers.intersection(this.methodMatcher, other.getMethodMatcher()); return this; }
@Test public void testUnion() { assertTrue(exceptionFilter.matches(RuntimeException.class)); assertFalse(exceptionFilter.matches(TestBean.class)); assertFalse(itbFilter.matches(Exception.class)); assertTrue(itbFilter.matches(TestBean.class)); ClassFilter union = ClassFilters.union(exceptionFilter, itbFilter); assertTrue(union.matches(RuntimeException.class)); assertTrue(union.matches(TestBean.class)); }
@Test public void testIntersection() { assertTrue(exceptionFilter.matches(RuntimeException.class)); assertTrue(hasRootCauseFilter.matches(NestedRuntimeException.class)); ClassFilter intersection = ClassFilters.intersection(exceptionFilter, hasRootCauseFilter); assertFalse(intersection.matches(RuntimeException.class)); assertFalse(intersection.matches(TestBean.class)); assertTrue(intersection.matches(NestedRuntimeException.class)); }
/** * Apply a union with the given ClassFilter. * @param other the ClassFilter to apply a union with * @return this composable pointcut (for call chaining) */ public ComposablePointcut union(ClassFilter other) { this.classFilter = ClassFilters.union(this.classFilter, other); return this; }
/** * Apply an intersection with the given ClassFilter. * @param other the ClassFilter to apply an intersection with * @return this composable pointcut (for call chaining) */ public ComposablePointcut intersection(ClassFilter other) { this.classFilter = ClassFilters.intersection(this.classFilter, other); return this; }
/** * Apply a union with the given ClassFilter. * @param other the ClassFilter to apply a union with * @return this composable pointcut (for call chaining) */ public ComposablePointcut union(ClassFilter other) { this.classFilter = ClassFilters.union(this.classFilter, other); return this; }
/** * Apply an intersection with the given ClassFilter. * @param other the ClassFilter to apply an intersection with * @return this composable pointcut (for call chaining) */ public ComposablePointcut intersection(ClassFilter other) { this.classFilter = ClassFilters.intersection(this.classFilter, other); return this; }
public ComposablePointcut union(ClassFilter filter) { this.classFilter = ClassFilters.union(this.classFilter, filter); return this; }
public ComposablePointcut intersection(ClassFilter filter) { this.classFilter = ClassFilters.intersection(this.classFilter, filter); return this; }
public ClassFilter getClassFilter() { return ClassFilters.union(a.getClassFilter(), b.getClassFilter()); }
/** * Private constructor to share common code between impl-based delegate and reference-based delegate * (cannot use method such as init() to share common code, due the use of final fields). * @param interfaceType static field defining the introduction * @param typePattern type pattern the introduction is restricted to * @param interceptor the delegation advice as {@link IntroductionInterceptor} */ private DeclareParentsAdvisor(Class<?> interfaceType, String typePattern, IntroductionInterceptor interceptor) { this.advice = interceptor; this.introducedInterface = interfaceType; // Excludes methods implemented. ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern); ClassFilter exclusion = (clazz -> !this.introducedInterface.isAssignableFrom(clazz)); this.typePatternClassFilter = ClassFilters.intersection(typePatternFilter, exclusion); }
/** * Apply a union with the given Pointcut. * <p>Note that for a Pointcut union, methods will only match if their * original ClassFilter (from the originating Pointcut) matches as well. * MethodMatchers and ClassFilters from different Pointcuts will never * get interleaved with each other. * @param other the Pointcut to apply a union with * @return this composable pointcut (for call chaining) */ public ComposablePointcut union(Pointcut other) { this.methodMatcher = MethodMatchers.union( this.methodMatcher, this.classFilter, other.getMethodMatcher(), other.getClassFilter()); this.classFilter = ClassFilters.union(this.classFilter, other.getClassFilter()); return this; }
/** * Private constructor to share common code between impl-based delegate and reference-based delegate * (cannot use method such as init() to share common code, due the use of final fields) * @param interfaceType static field defining the introduction * @param typePattern type pattern the introduction is restricted to * @param interceptor the delegation advice as {@link IntroductionInterceptor} */ private DeclareParentsAdvisor(Class<?> interfaceType, String typePattern, IntroductionInterceptor interceptor) { this.advice = interceptor; this.introducedInterface = interfaceType; // Excludes methods implemented. ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern); ClassFilter exclusion = new ClassFilter() { @Override public boolean matches(Class<?> clazz) { return !introducedInterface.isAssignableFrom(clazz); } }; this.typePatternClassFilter = ClassFilters.intersection(typePatternFilter, exclusion); }
/** * Apply a union with the given Pointcut. * <p>Note that for a Pointcut union, methods will only match if their * original ClassFilter (from the originating Pointcut) matches as well. * MethodMatchers and ClassFilters from different Pointcuts will never * get interleaved with each other. * @param other the Pointcut to apply a union with * @return this composable pointcut (for call chaining) */ public ComposablePointcut union(Pointcut other) { this.methodMatcher = MethodMatchers.union( this.methodMatcher, this.classFilter, other.getMethodMatcher(), other.getClassFilter()); this.classFilter = ClassFilters.union(this.classFilter, other.getClassFilter()); return this; }
/** * Apply an intersection with the given Pointcut. * @param other the Pointcut to apply an intersection with * @return this composable pointcut (for call chaining) */ public ComposablePointcut intersection(Pointcut other) { this.classFilter = ClassFilters.intersection(this.classFilter, other.getClassFilter()); this.methodMatcher = MethodMatchers.intersection(this.methodMatcher, other.getMethodMatcher()); return this; }
public ComposablePointcut intersection(Pointcut other) { this.classFilter = ClassFilters.intersection(this.classFilter, other.getClassFilter()); this.methodMatcher = MethodMatchers.intersection(this.methodMatcher, other.getMethodMatcher()); return this; }