package com.srbenoit.util;

import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 * A file filter that allows only directories.
 */
public class DirectoryFilter extends FileFilter {

    /**
     * Gets the description of the filter.
     *
     * @return  the description of the filter
     */
    @Override public String getDescription() {

        return "Directories";
    }

    /**
     * The filter function, which accepts only directories.
     *
     * @param   file  the file being tested
     * @return  <code>true</code> if the file is a directory; <code>false</code> otherwise
     */
    @Override public boolean accept(final File file) {

        return file.isDirectory();
    }
}
