|
1 |
| package com.agical.rmock.core.match.constraint.method; |
|
2 |
| |
|
3 |
| import java.lang.reflect.Method; |
|
4 |
| |
|
5 |
| import com.agical.rmock.core.match.Expression; |
|
6 |
| import com.agical.rmock.core.match.constraint.AbstractConstraint; |
|
7 |
| |
|
8 |
| public class MethodNameConstraint extends AbstractConstraint { |
|
9 |
| |
|
10 |
| private final Expression reference; |
|
11 |
| |
|
12 |
4
| public MethodNameConstraint(Expression reference) {
|
|
13 |
4
| super("name", reference);
|
|
14 |
4
| this.reference = reference;
|
|
15 |
| } |
|
16 |
| |
|
17 |
3
| public boolean passes(Object object) {
|
|
18 |
3
| if (object != null && object instanceof Method) {
|
|
19 |
1
| return reference.passes(((Method)object).getName());
|
|
20 |
| } |
|
21 |
2
| return false;
|
|
22 |
| } |
|
23 |
| } |