<commit_before>package net.morimekta.providence.storage;

import net.morimekta.providence.PMessage;
import net.morimekta.providence.PMessageBuilder;
import net.morimekta.providence.descriptor.PField;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;

import static net.morimekta.providence.storage.MessageStoreUtils.mutateAll;

/**
 * Interface for searching a store for a specific search S.
 *
 * @param <S> Search param, be it single string or struct or union with search parameters.
 * @param <M> PMessage that we search for.
 * @param <F> PField of M.
 */
public interface MessageSearcher<S, M extends PMessage<M, F>, F extends PField> {

    /**
     * Get a list of builders for the search input. Any modifications
     * to the returned builders will not be reflected onto the store.
     *
     * @param search The key to look up.
     * @param <B>    The builder type.
     * @return List of builders that matches search S.
     */
    @Nullable
    @SuppressWarnings("unchecked")
    default <B extends PMessageBuilder<M, F>>
    List<B> searchBuilders(@Nonnull S search) {
        return mutateAll(search(search));
    }

    /**
     * Look up a set of keys from the storage.
     *
     * @param search The search to query.
     * @return List of all M that matches Search S.
     */
    @Nonnull
    List<M> search(@Nonnull S search);

}<commit_msg>Changes S to Q as generic.<commit_after>package net.morimekta.providence.storage;

import net.morimekta.providence.PMessage;
import net.morimekta.providence.PMessageBuilder;
import net.morimekta.providence.descriptor.PField;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;

import static net.morimekta.providence.storage.MessageStoreUtils.mutateAll;

/**
 * Interface for searching a store for a specific search S.
 *
 * @param <Q> Search param, be it single string or struct or union with search parameters.
 * @param <M> PMessage that we search for.
 * @param <F> PField of M.
 */
public interface MessageSearcher<Q, M extends PMessage<M, F>, F extends PField> {

    /**
     * Get a list of builders for the query input. Any modifications
     * to the returned builders will not be reflected onto the store.
     *
     * @param query The key to look up.
     * @param <B>    The builder type.
     * @return List of builders that matches query Q.
     */
    @Nullable
    @SuppressWarnings("unchecked")
    default <B extends PMessageBuilder<M, F>>
    List<B> searchBuilders(@Nonnull Q query) {
        return mutateAll(search(query));
    }

    /**
     * Look up a set of keys from the storage.
     *
     * @param query The search to query.
     * @return List of all M that matches Query Q.
     */
    @Nonnull
    List<M> search(@Nonnull Q query);

}
{'fraction_non_alphanumeric': 0.09491645929612513, 'fraction_numerical': 0.0, 'mean_word_length': 3.168888888888889, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '4674154', 'n_tokens_mistral': 846, 'n_tokens_neox': 838, 'n_words': 301}