<commit_before>package com.qrokodial.sparkle.events.emission;

import com.qrokodial.sparkle.events.Event;
import com.qrokodial.sparkle.events.EventSubscriber;
import com.qrokodial.sparkle.events.filtering.IgnoreExcept;
import com.qrokodial.sparkle.events.filtering.ListenerFilter;
import com.qrokodial.sparkle.events.util.Priority;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class EventListener implements Comparable<EventListener> {
    private Object instance;
    private Method method;
    private EventSubscriber subscriber;
    private List<ListenerFilter> filters;

    /**
     * Constructs the class.
     *
     * @param instance
     * @param method
     * @param subscriber
     * @param filters
     */
    public EventListener(Object instance, Method method, EventSubscriber subscriber, ListenerFilter... filters) {
        this.instance = instance;
        this.method = method;
        this.subscriber = subscriber;
        this.filters = Collections.synchronizedList(Arrays.asList(filters));

        if (subscriber.requires().length > 0) {
            this.filters.add(new IgnoreExcept(subscriber.requires()));
        }
    }

    /**
     * @return the priority that this event listener has
     */
    public Priority getPriority() {
        return getSubscriber().priority();
    }

    /**
     * @return the instance of the listener that owns this {@link #getMethod()}
     */
    public Object getInstance() {
        return instance;
    }

    /**
     * @return the method to be invoked when an event is fired
     */
    public Method getMethod() {
        return method;<commit_msg>Switch to a mutable array for filters<commit_after>package com.qrokodial.sparkle.events.emission;

import com.qrokodial.sparkle.events.Event;
import com.qrokodial.sparkle.events.EventSubscriber;
import com.qrokodial.sparkle.events.filtering.IgnoreExcept;
import com.qrokodial.sparkle.events.filtering.ListenerFilter;
import com.qrokodial.sparkle.events.util.Priority;
import com.qrokodial.sparkle.utilities.collections.ArrayUtils;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class EventListener implements Comparable<EventListener> {
    private Object instance;
    private Method method;
    private EventSubscriber subscriber;
    private List<ListenerFilter> filters;

    /**
     * Constructs the class.
     *
     * @param instance
     * @param method
     * @param subscriber
     * @param filters
     */
    public EventListener(Object instance, Method method, EventSubscriber subscriber, ListenerFilter... filters) {
        this.instance = instance;
        this.method = method;
        this.subscriber = subscriber;
        this.filters = Collections.synchronizedList(Arrays.stream(filters).collect(Collectors.toList()));

        if (subscriber.requires().length > 0) {
            this.filters.add(new IgnoreExcept(subscriber.requires()));
        }
    }

    /**
     * @return the priority that this event listener has
     */
    public Priority getPriority() {
        return getSubscriber().priority();
    }

    /**
     * @return the instance of the listener that owns this {@link #getMethod()}
     */
    public Object getInstance() {
        return instance;
    }

    /**
     * @return the method to be invoked when an event is fired
     */
    public Method getMethod() {
        return method;
{'fraction_non_alphanumeric': 0.09851403412217942, 'fraction_numerical': 0.000550357732526142, 'mean_word_length': 3.144811858608894, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '6721753', 'n_tokens_mistral': 1028, 'n_tokens_neox': 1000, 'n_words': 243}