class ActionListeners {

    private ActionListeners() {
    }

    public static <T extends AcknowledgedResponse> ActionListener<T> waitForShards(ActionListener<T> delegate,
                                                                                   ActiveShardsObserver observer,
                                                                                   TimeValue timeout,
                                                                                   Runnable onShardsNotAcknowledged,
                                                                                   Supplier<String[]> indices) {<FILL_FUNCTION_BODY>}
}


        return ActionListener.wrap(
            resp -> {
                if (resp.isAcknowledged()) {
                    observer.waitForActiveShards(
                        indices.get(),
                        ActiveShardCount.DEFAULT,
                        timeout,
                        shardsAcknowledged -> {
                            if (!shardsAcknowledged) {
                                onShardsNotAcknowledged.run();
                            }
                            delegate.onResponse(resp);
                        },
                        delegate::onFailure
                    );
                } else {
                    delegate.onResponse(resp);
                }
            },
            delegate::onFailure
        );
    
<no_super_class>