/*
 * Copyright (c) 2009 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.reflection;

import com.jscape.util.functor.UnaryPredicate;

import java.lang.reflect.Method;
import java.util.regex.Pattern;

/**
 * @author Alex Usun
 */
public class MethodNameEquals
        extends UnaryPredicate<Method> {

    private final Pattern regex;

    public MethodNameEquals(String regex) {
        this.regex = Pattern.compile(regex);
    }

    public boolean evaluate(Method value) {
        return this.regex.matcher(value.getName()).matches();
    }

    public String toString() {
        return "MethodNamePredicate{"
                + "regex='" + this.regex + '\''
                + '}';
    }
}
