Java Code Examples for org.apache.commons.lang3.StringUtils.indexOfAny()

The following are Jave code examples for showing how to use indexOfAny() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: smarti   File: MltConfig.java   Source Code and License Vote up 6 votes
public Map.Entry<String,Collection<String>> getSimilarityFields(String lang, boolean fallback) {
    lang = StringUtils.lowerCase(lang, Locale.ROOT);
    Collection<String> langFields = langSimilarityFields.get(lang);
    if(fallback){
        int sepIdx = StringUtils.indexOfAny(lang, '-','_');
        if(sepIdx > 0){
            lang = lang.substring(0, sepIdx);
            langFields = langSimilarityFields.get(lang);
        }
        if(langFields == null && lang != null){
            lang = null;
            langFields = langSimilarityFields.get(lang);
        }
    } //else no fallback
    return langFields == null ? null : new ImmutablePair<>(lang, langFields);
}