SamePropertyValuesAs (Hamcrest 2.1 API)
Date: 2018-12-21

org.hamcrest.beans

## Class SamePropertyValuesAs<T>

- java.lang.Object
- - org.hamcrest.BaseMatcher<T>
  - - org.hamcrest.DiagnosingMatcher<T>
    - - org.hamcrest.beans.SamePropertyValuesAs<T>

- All Implemented Interfaces:
    Matcher<T>, SelfDescribing

      public class SamePropertyValuesAs<T>
      extends DiagnosingMatcher<T>

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SamePropertyValuesAs(T expectedBean, java.util.List<java.lang.String> ignoredProperties)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `describeTo(Description description)` Generates a description of the object.
    `protected boolean` | `matches(java.lang.Object actual, Description mismatch)`
    `static <B> Matcher<B>` | `samePropertyValuesAs(B expectedBean, java.lang.String... ignoredProperties)` Creates a matcher that matches when the examined object has values for all of its JavaBean properties that are equal to the corresponding values of the specified bean.

    - ### Methods inherited from class org.hamcrest.DiagnosingMatcher

      `describeMismatch, matches`

    - ### Methods inherited from class org.hamcrest.BaseMatcher

      `_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SamePropertyValuesAs

          public SamePropertyValuesAs(T expectedBean,
                                      java.util.List<java.lang.String> ignoredProperties)

  - ### Method Detail

    - #### matches

          protected boolean matches(java.lang.Object actual,
                                    Description mismatch)

      Specified by:
        `matches` in class `DiagnosingMatcher<T>`

    - #### describeTo

          public void describeTo(Description description)

      Description copied from interface: `SelfDescribing`
      Generates a description of the object. The description may be part of a a description of a larger object of which this is just a component, so it should be worded appropriately.
      Parameters:
        `description` - The description to be built or appended to.

    - #### samePropertyValuesAs

          public static <B> Matcher<B> samePropertyValuesAs(B expectedBean,
                                                            java.lang.String... ignoredProperties)

      Creates a matcher that matches when the examined object has values for all of its JavaBean properties that are equal to the corresponding values of the specified bean. If any properties are marked as ignored, they will be dropped from both the expected and actual bean. Note that the ignored properties use JavaBean display names, for example

          age

      rather than method names such as

          getAge

      . For example:

          assertThat(myBean, samePropertyValuesAs(myExpectedBean))

          assertThat(myBean, samePropertyValuesAs(myExpectedBean), "age", "height")

      Parameters:
        `expectedBean` - the bean against which examined beans are compared
        `ignoredProperties` - do not check any of these named properties.