use lambda to simplify the code (#1105)

pull/1107/head
邓联龙 2 years ago committed by GitHub
parent 5e524fab44
commit 0aa2c22bed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -76,9 +76,7 @@ public class DynamicThreadPoolAdapterChoose {
*/ */
public static void replace(Object executor, Executor dynamicThreadPoolExecutor) { public static void replace(Object executor, Executor dynamicThreadPoolExecutor) {
Optional<DynamicThreadPoolAdapter> dynamicThreadPoolAdapterOptional = DYNAMIC_THREAD_POOL_ADAPTERS.stream().filter(each -> each.match(executor)).findFirst(); Optional<DynamicThreadPoolAdapter> dynamicThreadPoolAdapterOptional = DYNAMIC_THREAD_POOL_ADAPTERS.stream().filter(each -> each.match(executor)).findFirst();
if (dynamicThreadPoolAdapterOptional.isPresent()) { dynamicThreadPoolAdapterOptional.ifPresent(dynamicThreadPoolAdapter -> dynamicThreadPoolAdapter.replace(executor, dynamicThreadPoolExecutor));
dynamicThreadPoolAdapterOptional.get().replace(executor, dynamicThreadPoolExecutor);
}
} }
/** /**

Loading…
Cancel
Save