class IndicesStatsResponse extends BroadcastResponse {

    private final ShardStats[] shards;

    IndicesStatsResponse(ShardStats[] shards, int totalShards, int successfulShards, int failedShards,
                         List<DefaultShardOperationFailedException> shardFailures) {
        super(totalShards, successfulShards, failedShards, shardFailures);
        this.shards = shards;
    }

    public ShardStats[] getShards() {
        return this.shards;
    }

    public IndexStats getIndex(String index) {
        return getIndices().get(index);
    }

    private Map<String, IndexStats> indicesStats;

    public Map<String, IndexStats> getIndices() {<FILL_FUNCTION_BODY>}

    public IndicesStatsResponse(StreamInput in) throws IOException {
        super(in);
        shards = in.readArray(ShardStats::new, ShardStats[]::new);
    }

    @Override
    public void writeTo(StreamOutput out) throws IOException {
        super.writeTo(out);
        out.writeArray(shards);
    }
}

        if (indicesStats != null) {
            return indicesStats;
        }
        Map<String, IndexStats> indicesStats = new HashMap<>();

        Set<Index> indices = new HashSet<>();
        for (ShardStats shard : shards) {
            indices.add(shard.getShardRouting().index());
        }

        for (Index index : indices) {
            List<ShardStats> shards = new ArrayList<>();
            String indexName = index.getName();
            for (ShardStats shard : this.shards) {
                if (shard.getShardRouting().getIndexName().equals(indexName)) {
                    shards.add(shard);
                }
            }
            indicesStats.put(
                indexName, new IndexStats(indexName, index.getUUID(), shards.toArray(new ShardStats[0]))
            );
        }
        this.indicesStats = indicesStats;
        return indicesStats;
    
<methods>public void <init>(int, int, int, List<org.elasticsearch.action.support.DefaultShardOperationFailedException>) ,public void <init>(org.elasticsearch.common.io.stream.StreamInput) throws java.io.IOException,public int getFailedShards() ,public org.elasticsearch.action.support.DefaultShardOperationFailedException[] getShardFailures() ,public org.elasticsearch.rest.RestStatus getStatus() ,public int getSuccessfulShards() ,public int getTotalShards() ,public void writeTo(org.elasticsearch.common.io.stream.StreamOutput) throws java.io.IOException<variables>public static final org.elasticsearch.action.support.DefaultShardOperationFailedException[] EMPTY,private final non-sealed int failedShards,private final non-sealed org.elasticsearch.action.support.DefaultShardOperationFailedException[] shardFailures,private final non-sealed int successfulShards,private final non-sealed int totalShards