All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.coode.parsers.ui.autocompletionmatcher.MultipleAutoCompletionMatcher Maven / Gradle / Ivy

package org.coode.parsers.ui.autocompletionmatcher;

import static org.coode.oppl.utils.ArgCheck.checkNotNull;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/** Combines more than one AutoCompletionMatcher.
 * 
 * @author Luigi Iannone */
public final class MultipleAutoCompletionMatcher implements AutoCompletionMatcher {
    private final Set matchers = new HashSet();

    /** @param matchers
     *            matchers */
    public MultipleAutoCompletionMatcher(
            Collection matchers) {
        this.matchers.addAll(checkNotNull(matchers, "matchers"));
    }

    @Override
    public List getMatches(String string2Complete) {
        checkNotNull(string2Complete, "string2Complete");
        List toReturn = new ArrayList();
        for (AutoCompletionMatcher matcher : matchers) {
            toReturn.addAll(matcher.getMatches(string2Complete));
        }
        Collections.sort(toReturn);
        return toReturn;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy