View Javadoc
1   package com.google.code.beanmatchers;
2   
3   import static java.util.Arrays.asList;
4   
5   import java.util.List;
6   import org.hamcrest.Description;
7   
8   public class HasValidBeanHashCodeForMatcher<T> extends AbstractBeanHashCodeMatcher<T> {
9     private final List<String> properties;
10  
11    HasValidBeanHashCodeForMatcher(TypeBasedValueGenerator valueGenerator, String... properties) {
12      super(valueGenerator);
13      this.properties = asList(properties);
14    }
15  
16    @Override
17    protected boolean matchesSafely(Class<T> beanType, Description mismatchDescription) {
18      return super.hashCodeIsInfluencedByProperties(
19          new JavaBean(beanType), properties, mismatchDescription);
20    }
21  
22    @Override
23    public void describeTo(Description description) {
24      description.appendText("bean with the properties ");
25      description.appendValue(properties);
26      description.appendText(" influencing hashCode");
27    }
28  }