Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

method name matcher #164

Closed
gissuebot opened this issue Jul 7, 2014 · 3 comments
Closed

method name matcher #164

gissuebot opened this issue Jul 7, 2014 · 3 comments

Comments

@gissuebot
Copy link

@gissuebot gissuebot commented Jul 7, 2014

From AaronJWhiteside on November 13, 2007 21:11:40

It would be useful to be able to match methods for interception based on
method name (and/or param list).

Original issue: http://code.google.com/p/google-guice/issues/detail?id=164

@gissuebot
Copy link
Author

@gissuebot gissuebot commented Jul 7, 2014

From AaronJWhiteside on November 13, 2007 18:22:54

additional: this allows one to match methods like toString(), finalize(), wait(),
whatever, etc.. in say the default java.lang.Object class without having to apply
annotations everywhere..

@gissuebot
Copy link
Author

@gissuebot gissuebot commented Jul 7, 2014

From AaronJWhiteside on November 18, 2007 20:40:24

public class MethodCalledMatcher
extends AbstractMatcher<Method>
{
    public static Matcher<Method> methodCalled(String methodName)
    {
        return new MethodCalledMatcher(methodName);
    }

    private String methodName;

    public MethodCalledMatcher(String methodName)
    {
        Objects.nonNull(methodName, "method name");        
        this.methodName = methodName;
    }

    @Override
    public boolean matches(Method method) {
        return method.getName().equals(methodName);
    }

    @Override
    public String toString() {
        return "methodCalled(" + methodName + ")";
    }
}

@gissuebot
Copy link
Author

@gissuebot gissuebot commented Jul 7, 2014

From limpbizkit on May 16, 2008 09:31:50

Anyone interested in this can use the code above. We won't add this functionality to core Guice for the reasons
crazybob describes here: http://groups.google.com/group/google-guice/browse_frm/thread/1330ed84618d57b4/c40843d874a4833c? #c40843d874a4833c

Status: WontFix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant