@@ -55,7 +55,7 @@ static boolean hasParamDescriptor(MethodOutline method, int paramIndex, String p
5555 }
5656
5757 /** Does the method's descriptor contain a matching parameter type at the given index? */
58- static boolean hasParamType (MethodOutline method , int paramIndex , Predicate < String > typeMatcher ) {
58+ static boolean hasParamType (MethodOutline method , int paramIndex , TypeMatcher typeMatcher ) {
5959 // boundaries covers start of second parameter, to start of return descriptor
6060 int [] boundaries = method .descriptorBoundaries ();
6161 if (paramIndex >= boundaries .length ) { // ignore return descriptor boundary
@@ -70,7 +70,7 @@ static boolean hasParamType(MethodOutline method, int paramIndex, Predicate<Stri
7070 }
7171
7272 /** Does the method's descriptor contain a matching return type? */
73- static boolean hasReturnType (MethodOutline method , Predicate < String > typeMatcher ) {
73+ static boolean hasReturnType (MethodOutline method , TypeMatcher typeMatcher ) {
7474 // boundaries covers start of second parameter, to start of return descriptor
7575 int [] boundaries = method .descriptorBoundaries ();
7676 // return type starts at 2 if no parameters, otherwise check last boundary
@@ -82,7 +82,7 @@ static boolean hasReturnType(MethodOutline method, Predicate<String> typeMatcher
8282 }
8383
8484 /** Does the field's descriptor contain a matching type? */
85- static boolean hasFieldType (FieldOutline field , Predicate < String > typeMatcher ) {
85+ static boolean hasFieldType (FieldOutline field , TypeMatcher typeMatcher ) {
8686 String descriptor = field .descriptor ;
8787 // extract type from "L...;" descriptor string, ignore primitive/array types
8888 return descriptor .charAt (0 ) == 'L'
@@ -247,6 +247,40 @@ public boolean test(MethodOutline outline) {
247247 }
248248 }
249249
250+ /** Logical AND of two {@link TypeMatcher}s; nested conjunctions will be collapsed. */
251+ static final class TypeConjunction extends MatcherUnion <TypeMatcher > implements TypeMatcher {
252+ TypeConjunction (TypeMatcher lhs , TypeMatcher rhs ) {
253+ super (new TypeMatcher [] {lhs , rhs });
254+ }
255+
256+ @ Override
257+ public boolean test (CharSequence typeString ) {
258+ for (TypeMatcher matcher : matchers ) {
259+ if (!matcher .test (typeString )) {
260+ return false ;
261+ }
262+ }
263+ return true ;
264+ }
265+ }
266+
267+ /** Logical OR of two {@link TypeMatcher}s; nested disjunctions will be collapsed. */
268+ static final class TypeDisjunction extends MatcherUnion <TypeMatcher > implements TypeMatcher {
269+ TypeDisjunction (TypeMatcher lhs , TypeMatcher rhs ) {
270+ super (new TypeMatcher [] {lhs , rhs });
271+ }
272+
273+ @ Override
274+ public boolean test (CharSequence typeString ) {
275+ for (TypeMatcher matcher : matchers ) {
276+ if (matcher .test (typeString )) {
277+ return true ;
278+ }
279+ }
280+ return false ;
281+ }
282+ }
283+
250284 /** Logical union of two matchers; nested unions of the same type will be collapsed. */
251285 abstract static class MatcherUnion <M > {
252286 protected final M [] matchers ;
0 commit comments