<commit_before>package org.dominokit.domino.api.client.extension;

import org.dominokit.domino.api.shared.extension.EventContext;

import java.util.LinkedHashSet;
import java.util.Set;

public class ContextAggregator {

    private Set<ContextWait> contextsSet=new LinkedHashSet<>();

    private ContextAggregator(Set<ContextWait> contextSet,
                              ReadyHandler handler) {
        this.contextsSet=contextSet;
        this.contextsSet.forEach(c-> c.onReady(() -> {
            this.contextsSet.remove(c);
            if(this.contextsSet.isEmpty())
                handler.onReady();
        }));
    }

    public static CanWaitForContext waitFor(ContextWait context){
        return ContextAggregatorBuilder.waitForContext(context);
    }

    public interface CanWaitForContext{
        CanWaitForContext and(ContextWait context);
        ContextAggregator onReady(ReadyHandler handler);
    }

    @FunctionalInterface
    public interface ReadyHandler{
        void onReady();
    }

    private static class ContextAggregatorBuilder implements CanWaitForContext {

        private Set<ContextWait> contextSet=new LinkedHashSet<>();

        private ContextAggregatorBuilder(ContextWait context) {
            this.contextSet.add(context);
        }

        public static CanWaitForContext waitForContext(ContextWait context){
            return new ContextAggregatorBuilder(context);
        }

        @Override
        public CanWaitForContext and(ContextWait context) {
            this.contextSet.add(context);
            return this;
        }

        @Override
        public ContextAggregator onReady(ReadyHandler handler) {
            return new ContextAggregator(contextSet, handler);
        }
    }

    public static class ContextWait<T extends EventContext>{
        private Set<ReadyHandler> readyHandlers=new LinkedHashSet<>();
        private T context;

        public static <T extends EventContext> ContextWait<T> create(){
            return new ContextWait<>();
        }

        void onReady(ReadyHandler handler){
            this.readyHandlers.add(handler);
        }

        public void receiveContext(T context){
            this.context=context;
            readyHandlers.forEach(ReadyHandler::onReady);
        }

        public T get(){
            return context;
        }
    }
}<commit_msg>allow any object in the context aggregator<commit_after>package org.dominokit.domino.api.client.extension;

import java.util.LinkedHashSet;
import java.util.Set;

public class ContextAggregator {

    private Set<ContextWait> contextsSet=new LinkedHashSet<>();

    private ContextAggregator(Set<ContextWait> contextSet,
                              ReadyHandler handler) {
        this.contextsSet=contextSet;
        this.contextsSet.forEach(c-> c.onReady(() -> {
            this.contextsSet.remove(c);
            if(this.contextsSet.isEmpty())
                handler.onReady();
        }));
    }

    public static CanWaitForContext waitFor(ContextWait context){
        return ContextAggregatorBuilder.waitForContext(context);
    }

    public interface CanWaitForContext{
        CanWaitForContext and(ContextWait context);
        ContextAggregator onReady(ReadyHandler handler);
    }

    @FunctionalInterface
    public interface ReadyHandler{
        void onReady();
    }

    private static class ContextAggregatorBuilder implements CanWaitForContext {

        private Set<ContextWait> contextSet=new LinkedHashSet<>();

        private ContextAggregatorBuilder(ContextWait context) {
            this.contextSet.add(context);
        }

        public static CanWaitForContext waitForContext(ContextWait context){
            return new ContextAggregatorBuilder(context);
        }

        @Override
        public CanWaitForContext and(ContextWait context) {
            this.contextSet.add(context);
            return this;
        }

        @Override
        public ContextAggregator onReady(ReadyHandler handler) {
            return new ContextAggregator(contextSet, handler);
        }
    }

    public static class ContextWait<T>{
        private Set<ReadyHandler> readyHandlers=new LinkedHashSet<>();
        private T context;

        public static <T> ContextWait<T> create(){
            return new ContextWait<>();
        }

        void onReady(ReadyHandler handler){
            this.readyHandlers.add(handler);
        }

        public void receiveContext(T context){
            this.context=context;
            readyHandlers.forEach(ReadyHandler::onReady);
        }

        public T get(){
            return context;
        }
    }
}
{'fraction_non_alphanumeric': 0.08209437621202327, 'fraction_numerical': 0.0, 'mean_word_length': 2.469357249626308, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6966189', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1143, 'n_words': 250}