1
2
3
4 package com.lexicalscope.fluentreflection;
5
6 import org.apache.commons.lang3.builder.EqualsBuilder;
7 import org.hamcrest.Description;
8
9 final class MatcherReflectingOn extends ReflectionMatcher<FluentClass<?>> {
10 private final Class<?> klass;
11
12 MatcherReflectingOn(final Class<?> klass) {
13 this.klass = klass;
14 }
15
16 @Override public boolean matchesSafely(final FluentClass<?> arg) {
17 return arg.classUnderReflection().equals(klass);
18 }
19
20 @Override public void describeTo(final Description description) {
21 description.appendText("type ").appendValue(klass);
22 }
23
24 @Override public final boolean equals(final Object obj) {
25 if (obj != null && obj.getClass().equals(this.getClass())) {
26 return new EqualsBuilder()
27 .append(klass, ((MatcherReflectingOn) obj).klass)
28 .isEquals();
29 }
30 return false;
31 }
32
33 @Override public final int hashCode() {
34 return klass.hashCode();
35 }
36 }