package com.jscape.util.file;

import com.jscape.util.FileTools;
import com.jscape.util.functor.UnaryFunction;

import java.io.File;
import java.io.FileFilter;
import java.util.Collection;

/**
 * @author Alex Usun
 */
@SuppressWarnings("unchecked")
public class ListFiles
        extends UnaryFunction<File, Collection<File>> {

    /**
     * File filter.
     */
    private final FileFilter filter;

    /**
     * @param filter FileFilter instance
     */
    public ListFiles(FileFilter filter) {
        this.filter = filter;
    }

    /**
     * @param value File value
     *
     * @return Collection
     */
    public Collection<File> evaluate(File value) {
        return FileTools.listFiles(value, this.filter);
    }
}
