@@ -88,7 +88,7 @@ private void addActivityImplementation(
88
88
}
89
89
}
90
90
Set <MethodInterfacePair > activityMethods =
91
- getAnnotatedInterfaceMethods (cls , ActivityInterface .class );
91
+ getAnnotatedInterfaceMethodsFromImplementation (cls , ActivityInterface .class );
92
92
if (activityMethods .isEmpty ()) {
93
93
throw new IllegalArgumentException (
94
94
"Class doesn't implement any non empty interface annotated with @ActivityInterface: "
@@ -338,7 +338,7 @@ public int hashCode() {
338
338
}
339
339
}
340
340
341
- Set <MethodInterfacePair > getAnnotatedInterfaceMethods (
341
+ static Set <MethodInterfacePair > getAnnotatedInterfaceMethodsFromImplementation (
342
342
Class <?> implementationClass , Class <? extends Annotation > annotationClass ) {
343
343
if (implementationClass .isInterface ()) {
344
344
throw new IllegalArgumentException (
@@ -347,11 +347,33 @@ Set<MethodInterfacePair> getAnnotatedInterfaceMethods(
347
347
Set <MethodInterfacePair > pairs = new HashSet <>();
348
348
// Methods inherited from interfaces that are not annotated with @ActivityInterface
349
349
Set <MethodWrapper > ignored = new HashSet <>();
350
- getAnnotatedInterfaceMethods (implementationClass , annotationClass , ignored , pairs );
350
+ getAnnotatedInterfaceMethodsFromImplementation (
351
+ implementationClass , annotationClass , ignored , pairs );
351
352
return pairs ;
352
353
}
353
354
354
- private void getAnnotatedInterfaceMethods (
355
+ static Set <MethodInterfacePair > getAnnotatedInterfaceMethodsFromInterface (
356
+ Class <?> iClass , Class <? extends Annotation > annotationClass ) {
357
+ if (!iClass .isInterface ()) {
358
+ throw new IllegalArgumentException ("Interface expected. Found: " + iClass .getSimpleName ());
359
+ }
360
+ Annotation annotation = iClass .getAnnotation (annotationClass );
361
+ if (annotation == null ) {
362
+ throw new IllegalArgumentException (
363
+ "@ActivityInterface annotation is required on the stub interface: "
364
+ + iClass .getSimpleName ());
365
+ }
366
+ Set <MethodInterfacePair > pairs = new HashSet <>();
367
+ // Methods inherited from interfaces that are not annotated with @ActivityInterface
368
+ Set <MethodWrapper > ignored = new HashSet <>();
369
+ getAnnotatedInterfaceMethodsFromImplementation (iClass , annotationClass , ignored , pairs );
370
+ if (!ignored .isEmpty ()) {
371
+ throw new IllegalStateException ("Not empty ignored: " + ignored );
372
+ }
373
+ return pairs ;
374
+ }
375
+
376
+ private static void getAnnotatedInterfaceMethodsFromImplementation (
355
377
Class <?> current ,
356
378
Class <? extends Annotation > annotationClass ,
357
379
Set <MethodWrapper > methods ,
@@ -368,7 +390,8 @@ private void getAnnotatedInterfaceMethods(
368
390
Class <?>[] interfaces = current .getInterfaces ();
369
391
for (int i = 0 ; i < interfaces .length ; i ++) {
370
392
Class <?> anInterface = interfaces [i ];
371
- getAnnotatedInterfaceMethods (anInterface , annotationClass , ourMethods , result );
393
+ getAnnotatedInterfaceMethodsFromImplementation (
394
+ anInterface , annotationClass , ourMethods , result );
372
395
}
373
396
Annotation annotation = current .getAnnotation (annotationClass );
374
397
if (annotation == null ) {
0 commit comments