public < T > Callback < T > wrapCallbackWithTimeout ( final String operationDescription , final Callback < T > callback , final Logger logger , final TimeUnit timeUnit , final long timeoutDuration ) { return callbackBuilder ( ) . setCallback ( new Callback < T > ( ) { @ Override public void accept ( T t ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "{} returned {}" , operationDescription , t ) ; } callback . resolve ( t ) ; } } ) . setOnError ( error -> { logger . error ( String . format ( "ERROR calling %s" , operationDescription ) , error ) ; callback . onError ( error ) ; } ) . setOnTimeout ( ( ) -> { logger . error ( "TIMEOUT calling {}" , operationDescription ) ; callback . onTimeout ( ) ; } ) . setTimeoutTimeUnit ( timeUnit ) . setTimeoutDuration ( timeoutDuration ) . build ( ) ; }
Used for quickly delegating one callback to another . This allows one liners so you don t have to create a builder for this common case .