@ SuppressWarnings ( "TryWithIdenticalCatches" ) private void deliverResult ( @ NonNull final ChronosOperationResult < ? > operationResult , @ NonNull final String methodName , final boolean warnIfNoCallback ) { final Class listenerClass = mServiceListener . getClass ( ) ; final Method [ ] listenerMethods = listenerClass . getMethods ( ) ; Method callbackMethod = null ; final Class resultClass = operationResult . getClass ( ) ; for ( Method method : listenerMethods ) { if ( isCallback ( method , resultClass , methodName ) ) { callbackMethod = method ; try { callbackMethod . invoke ( mServiceListener , operationResult ) ; } catch ( IllegalAccessException e ) { Log . w ( LOG_TAG , Log . getStackTraceString ( e ) ) ; } catch ( InvocationTargetException e ) { Log . w ( LOG_TAG , Log . getStackTraceString ( e ) ) ; } } } if ( warnIfNoCallback && callbackMethod == null ) { Log . w ( LOG_TAG , "Operation result (id=" + operationResult . getId ( ) + "; class=" + operationResult . getClass ( ) . getName ( ) + ") was obtained, but there is no method in " + mServiceListener + " to get it" ) ; Log . w ( LOG_TAG , "Method should look like" ) ; Log . w ( LOG_TAG , "public void " + methodName + "(" + resultClass . getName ( ) + " result) {}" ) ; } }
Call bound client methods to pass an operation result .