1
2
3
4 package com.lexicalscope.fluentreflection;
5
6 import java.util.regex.Pattern;
7
8 import org.hamcrest.Description;
9
10 final class MatcherHasNameMatching extends ReflectionMatcher<FluentMember> {
11 private final String regex;
12 private final Pattern pattern;
13
14 MatcherHasNameMatching(final String regex) {
15 this.regex = regex;
16 pattern = Pattern.compile(regex);
17 }
18
19 @Override
20 public boolean matchesSafely(final FluentMember arg) {
21 return pattern.matcher(arg.name()).matches();
22 }
23
24 @Override
25 public void describeTo(final Description description) {
26 description.appendText("callable matching ").appendValue(regex);
27 }
28 }