@ Trivial private final static FutureRefExecutor supportsAsync ( Executor executor ) { if ( executor instanceof ExecutorService ) return new FutureRefExecutor ( ( ExecutorService ) executor ) ; // valid if ( executor instanceof UnusableExecutor ) throw new UnsupportedOperationException ( ) ; // not valid for executing tasks return null ; // valid }
Convenience method to validate that an executor supports running asynchronously and to wrap the executor if an ExecutorService with FutureRefExecutor . This method is named supportsAsync to make failure stacks more meaningful to users .