Example usage for org.apache.commons.collections.functors NotNullPredicate getInstance

List of usage examples for org.apache.commons.collections.functors NotNullPredicate getInstance

Introduction

In this page you can find the example usage for org.apache.commons.collections.functors NotNullPredicate getInstance.

Prototype

public static Predicate getInstance() 

Source Link

Document

Factory returning the singleton instance.

Usage

From source file:org.itracker.services.implementations.ConfigurationServiceImpl.java

public Map<String, List<String>> getAvailableLanguages() {

    final TreeMap<String, List<String>> languages = new TreeMap<>();
    final List<Configuration> locales = getConfigurationItemsByType(Configuration.Type.locale);

    for (int i = 0; i < locales.size(); i++) {
        String baselocalestring = locales.get(i).getValue();
        if (baselocalestring.length() == 2) {
            List<String> languageList = new ArrayList<>();
            final String l = baselocalestring;

            languageList.addAll(CollectionUtils.collect(locales, new Transformer() {
                @Override//ww  w  . ja  v a  2 s. com
                public Object transform(Object input) {
                    String val = ((Configuration) input).getValue();
                    if (val.length() > 2 && val.startsWith(l + "_")) {
                        return val;
                    }
                    return null;
                }
            }));
            CollectionUtils.filter(languageList, NotNullPredicate.getInstance());
            languages.put(baselocalestring, languageList);
        }
    }

    return languages;

}

From source file:org.squashtest.tm.web.internal.interceptor.ExcludeRequestInterceptorWrapper.java

/**
 * @param excludedExtensions/*from w  ww.  j a  va2s  .  co m*/
 *            the excludedExtensions to set
 */
@SuppressWarnings("unchecked")
public void setExcludedExtensions(String[] excludedExtensions) {
    Assert.parameterNotNull(excludedExtensions, "excludedExtensions");

    LOGGER.debug("Excluded extensions : {} ({} excluded extensions)", excludedExtensions,
            excludedExtensions.length); // had to cast to call the right method

    Collection<String> nonNullExtensions = CollectionUtils.select(Arrays.asList(excludedExtensions),
            NotNullPredicate.getInstance());

    this.excludedExtensions = CollectionUtils.collect(nonNullExtensions, new Transformer() {
        @Override
        public Object transform(Object input) {
            return ((String) input).trim().toLowerCase();
        }
    });
}