static void validateExceptions ( Binder binder , Iterable < TypeLiteral < ? > > actualExceptionTypes , Iterable < Class < ? extends Throwable > > expectedExceptionTypes , Class < ? extends CheckedProvider > checkedProvider ) { // Validate the exceptions in the method match the exceptions // in the CheckedProvider. for ( TypeLiteral < ? > exType : actualExceptionTypes ) { Class < ? > exActual = exType . getRawType ( ) ; // Ignore runtime exceptions & errors. if ( RuntimeException . class . isAssignableFrom ( exActual ) || Error . class . isAssignableFrom ( exActual ) ) { continue ; } boolean notAssignable = true ; for ( Class < ? extends Throwable > exExpected : expectedExceptionTypes ) { if ( exExpected . isAssignableFrom ( exActual ) ) { notAssignable = false ; break ; } } if ( notAssignable ) { binder . addError ( "%s is not compatible with the exceptions (%s) declared in " + "the CheckedProvider interface (%s)" , exActual , expectedExceptionTypes , checkedProvider ) ; } } }
Adds errors to the binder if the exceptions aren t valid .