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 HasValidBeanEqualsForMatcher<T> extends AbstractBeanEqualsMatcher<T> { 9 private final List<String> properties; 10 11 HasValidBeanEqualsForMatcher(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 isValidBeanEquals(beanType, properties, mismatchDescription); 19 } 20 21 @Override 22 public void describeTo(Description description) { 23 description.appendText("bean with the properties "); 24 description.appendValue(properties); 25 description.appendText(" compared in equals"); 26 } 27 }