### Question:
InstanceOfPredicate implements Predicate<T> { @Override public boolean equals(Object other) { return EqualsBuilder.reflectionEquals(this, other); } InstanceOfPredicate(Class<?> testClass); @Override boolean evaluate(T instance); @Override boolean equals(Object other); @Override int hashCode();  }### Answer:
@Test public void shouldBeEqualIfOtherIsAnInstanceOfPredicateOverTheSameClass() throws Exception { Predicate<Number> firstInstanceOfPredicate = new InstanceOfPredicate<Number>(Integer.class); Predicate<Number> secondInstanceOfPredicate = new InstanceOfPredicate<Number>(Integer.class); boolean equal = firstInstanceOfPredicate.equals(secondInstanceOfPredicate); assertThat(equal, is(true)); }
@Test public void shouldNotBeEqualIfOtherIsAnInstanceOfPredicateOverADifferentClass() throws Exception { Predicate<Number> firstInstanceOfPredicate = new InstanceOfPredicate<Number>(Integer.class); Predicate<Number> secondInstanceOfPredicate = new InstanceOfPredicate<Number>(Long.class); boolean equal = firstInstanceOfPredicate.equals(secondInstanceOfPredicate); assertThat(equal, is(false)); }
@Test public void shouldNotBeEqualIfOtherIsNotAnInstanceOfPredicate() throws Exception { Predicate<Number> firstInstanceOfPredicate = new InstanceOfPredicate<Number>(Integer.class); Predicate<Object> secondInstanceOfPredicate = alwaysFalse(); boolean equal = firstInstanceOfPredicate.equals(secondInstanceOfPredicate); assertThat(equal, is(false)); }