Example usage for org.apache.commons.collections CollectionUtils predicatedCollection

List of usage examples for org.apache.commons.collections CollectionUtils predicatedCollection

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils predicatedCollection.

Prototype

public static Collection predicatedCollection(Collection collection, Predicate predicate) 

Source Link

Document

Returns a predicated (validating) collection backed by the given collection.

Usage

From source file:com.google.mr4c.content.ContentTypes.java

public static Collection<String> filterByContentType(Collection<String> fileNames, final String contentType,
        final boolean canonicalOnly) {
    return CollectionUtils.predicatedCollection(fileNames, new Predicate() {
        public boolean evaluate(Object obj) {
            String name = (String) obj;
            if (canonicalOnly) {
                String suffix = ContentTypes.getSuffix(contentType);
                return FilenameUtils.isExtension(name, suffix);
            } else {
                Collection<String> suffixes = ContentTypes.getSuffixes(contentType);
                return FilenameUtils.isExtension(name, suffixes);
            }/* w ww. j  a va  2 s.  c om*/
        }
    });
}