/*
 * Copyright (c) 2008 JSCAPE
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JSCAPE. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JSCAPE.
 *
 */

package com.jscape.util.regex;

import com.jscape.util.Assert;

import java.io.File;
import java.io.FileFilter;

/**
 * @author Alex Usun
 */
public class FileMatcherFilter
        implements FileFilter {

    private final Matcher matcher;

    public FileMatcherFilter(Matcher matcher) {
        Assert.notNull(matcher);
        this.matcher = matcher;
    }

    public boolean accept(File pathname) {
        return pathname.isFile() && this.matcher.matches(pathname.getName());
    }

    @Override
    public String toString() {
        return "FileMatcherFilter {"
                + "matcher=" + this.matcher
                + '}';
    }
}
