// Path: dfalex/src/main/java/backport/java/util/function/Function.java
// public interface Function<T, R> {
// 
//     /**
//      * Returns a function that always returns its input argument.
//      *
//      * @param <T> the type of the input and output objects to the function
//      * @return a function that always returns its input argument
//      */
//     static <T> Function<T, T> identity() {
//         return t -> t;
//     }
// 
//     /**
//      * Applies this function to the given argument.
//      *
//      * @param t the function argument
//      * @return the function result
//      */
//      R apply(T t);
// }


import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import backport.java.util.function.Function;
import com.nobigsoftware.util.BuilderCache;
    public Function<String,String> buildStringReplacer()
    {
        if (m_dfaMemo == null)
        {
            m_dfaMemo = m_dfaBuilder.build(SearchAndReplaceBuilder::ambiguityResolver);
        }
        if (m_reverseFinderMemo == null)
        {
            m_reverseFinderMemo = m_dfaBuilder.buildReverseFinder();
        }
        final StringSearcher<Integer> searcher = new StringSearcher<>(m_dfaMemo, m_reverseFinderMemo);
        final StringSearcherReplacer replacer = new StringSearcherReplacer(m_replacements);
        return (str -> searcher.findAndReplace(str, replacer));
    }
    
    /**
     * Build a search and replace function from a searcher and replacer
     * 
     * @param searcher the searcher
     * @param replacer the replacer
     * @return The search+replace function
     */
    public static <MR> Function<String,String> buildFromSearcher(StringSearcher<MR> searcher, ReplacementSelector<? super MR> replacer)
    {
        return (str -> searcher.findAndReplace(str, replacer));
    }
    
    private void _clearMemos()
    {
        m_dfaMemo = null;
// Path: dfalex/src/main/java/backport/java/util/function/Function.java
// public interface Function<T, R> {
// 
//     /**
//      * Returns a function that always returns its input argument.
//      *
//      * @param <T> the type of the input and output objects to the function
//      * @return a function that always returns its input argument
//      */
//     static <T> Function<T, T> identity() {
//         return t -> t;
//     }
// 
//     /**
//      * Applies this function to the given argument.
//      *
//      * @param t the function argument
//      * @return the function result
//      */
//      R apply(T t);
// }


// Path: dfalex/src/main/java/com/nobigsoftware/dfalex/SearchAndReplaceBuilder.java
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import backport.java.util.function.Function;
import com.nobigsoftware.util.BuilderCache;

    public Function<String,String> buildStringReplacer()
    {
        if (m_dfaMemo == null)
        {
            m_dfaMemo = m_dfaBuilder.build(SearchAndReplaceBuilder::ambiguityResolver);
        }
        if (m_reverseFinderMemo == null)
        {
            m_reverseFinderMemo = m_dfaBuilder.buildReverseFinder();
        }
        final StringSearcher<Integer> searcher = new StringSearcher<>(m_dfaMemo, m_reverseFinderMemo);
        final StringSearcherReplacer replacer = new StringSearcherReplacer(m_replacements);
        return (str -> searcher.findAndReplace(str, replacer));
    }
    
    /**
     * Build a search and replace function from a searcher and replacer
     * 
     * @param searcher the searcher
     * @param replacer the replacer
     * @return The search+replace function
     */
    public static <MR> Function<String,String> buildFromSearcher(StringSearcher<MR> searcher, ReplacementSelector<? super MR> replacer)
    {
        return (str -> searcher.findAndReplace(str, replacer));
    }
    
    private void _clearMemos()
    {
        m_dfaMemo = null;
        m_reverseFinderMemo = null;