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 HasToStringDescribingPropertiesMatcher<T> extends AbstractBeanToStringMatcher<T> {
9
10
11 private final List<String> properties;
12
13 public HasToStringDescribingPropertiesMatcher(
14 TypeBasedValueGenerator valueGenerator, String... properties) {
15 super(valueGenerator);
16 this.properties = asList(properties);
17 }
18
19 @Override
20 protected boolean matchesSafely(Class beanType, Description mismatchDescription) {
21 return super.toStringDescribesProperties(beanType, properties, mismatchDescription);
22 }
23
24 public void describeTo(Description description) {
25 description.appendText("bean with toString() describing class name and the properties ");
26 description.appendValue(properties);
27 }
28 }