class DefaultReactiveSwitcher implements ReactiveSwitcher {

    private String name;

    private String defaultId;

    private String type;

    public DefaultReactiveSwitcher(String name,String type) {
        this.name = "ReactiveSwitcher.".concat(name);
        this.defaultId = name.concat(".").concat("_default");
        this.type=type;
    }

    @Deprecated
    private <R> Mono<R> doInContext(Function<Deque<String>, Mono<R>> function) {
        return ContextUtils.reactiveContext()
                .map(ctx -> ctx.getOrDefault(ContextKey.<Deque<String>>of(this.name), LinkedList::new))
                .flatMap(function);
    }

    @SuppressWarnings("all")
    private <R extends Publisher<?>> R  doInContext(R publisher, Consumer<Deque<String>> consumer) {<FILL_FUNCTION_BODY>}

    @Override
    public <P extends Publisher<?>> P  useLast(P publisher) {
        return doInContext(publisher,queue -> {
            // 没有上一次了
            if (queue.isEmpty()) {
                return;
            }
            //移除队尾,则当前的队尾则为上一次使用的配置
            queue.removeLast();
        });
    }


    @Override
    public <P extends Publisher<?>> P use(P publisher, String id) {
        return doInContext(publisher,queue-> queue.addLast(id));
    }

    @Override
    public <P extends Publisher<?>> P  useDefault(P publisher) {
        return  use(publisher,defaultId);
    }

    @Override
    public <P extends Publisher<?>> P  reset(P publisher) {
        return doInContext(publisher, Collection::clear);
    }

    @Override
    public Mono<String> current() {
        return doInContext(queue -> {
            if (queue.isEmpty()) {
                return Mono.empty();
            }

            String activeId = queue.getLast();
            if (defaultId.equals(activeId)) {
                return Mono.empty();
            }
            return Mono.just(activeId);
        });
    }


}

        if (publisher instanceof Mono) {
            return (R)((Mono<?>) publisher)
                    .contextWrite(ContextUtils.acceptContext(ctx -> {
                        consumer.accept(ctx.getOrDefault(ContextKey.<Deque<String>>of(this.name), LinkedList::new));
                    }));
        } else if (publisher instanceof Flux) {
            return (R)((Flux<?>) publisher)
                    .contextWrite(ContextUtils.acceptContext(ctx -> {
                        consumer.accept(ctx.getOrDefault(ContextKey.<Deque<String>>of(this.name), LinkedList::new));
                    }));
        }
        return publisher;
    
<no_super_class>