class SetMailboxesMethod implements Method {

    @Override
    public Stream<JmapResponse> processToStream(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession) {
        Preconditions.checkNotNull(request);
        Preconditions.checkNotNull(methodCallId);
        Preconditions.checkNotNull(mailboxSession);
        Preconditions.checkArgument(request instanceof SetMailboxesRequest);

        SetMailboxesRequest setMailboxesRequest = (SetMailboxesRequest) request;


        return MDCBuilder.create()
            .addContext(MDCBuilder.ACTION, "SET_MAILBOXES")
            .addContext("create", setMailboxesRequest.getCreate())
            .addContext("update", setMailboxesRequest.getUpdate())
            .addContext("destroy", setMailboxesRequest.getDestroy())
            .wrapArround(
                () -> metricFactory.decorateSupplierWithTimerMetricLogP99(JMAP_PREFIX + METHOD_NAME.getName(),
                    () -> Stream.of(
                        JmapResponse.builder().methodCallId(methodCallId)
                            .response(setMailboxesResponse(setMailboxesRequest, mailboxSession))
                            .responseName(RESPONSE_NAME)
                            .build())))
            .get();
    }

    @Inject public  SetMailboxesMethod(Set<SetMailboxesProcessor> processors, MetricFactory metricFactory);

}