T - A generic type to fit in the static typing with other matchers.public class HasPropertyPath<T>
extends org.hamcrest.TypeSafeDiagnosingMatcher<T>
| Modifier and Type | Method and Description |
|---|---|
void |
describeTo(org.hamcrest.Description description)
Describes the matcher.
|
static <T> org.hamcrest.Matcher<T> |
hasPropertyPath(String propertyPath)
Matches if the specified path to a property exist.
|
static <T> org.hamcrest.Matcher<T> |
hasPropertyPath(String propertyPath,
org.hamcrest.Matcher<?> valueMatcher)
Matches if the specified path to a property exists and the value of the last path element is matched by
valueMatcher. |
protected boolean |
matchesSafely(T t,
org.hamcrest.Description description) |
public static <T> org.hamcrest.Matcher<T> hasPropertyPath(String propertyPath)
hasPropertyPath("a.b.c") matches on
object, if object has a property a which has a property b
which then has a property c. It does not matter if property c has a value or not.T - A generic type to fit in the static typing with other matchers.propertyPath - The path to the desired property.public static <T> org.hamcrest.Matcher<T> hasPropertyPath(String propertyPath, org.hamcrest.Matcher<?> valueMatcher)
valueMatcher.
Example: The matcher hasPropertyPath("owner.pet.name", is("Pete") matches on object,
if object has a property owner which has a property pet which then has a
property name and name has the value "Pete".T - A generic type to fit in the static typing with other matchers.propertyPath - The path to the desired property.valueMatcher - A matcher for the last element in the property path.protected boolean matchesSafely(T t, org.hamcrest.Description description)
matchesSafely in class org.hamcrest.TypeSafeDiagnosingMatcher<T>public void describeTo(org.hamcrest.Description description)
description - The description object to append the matchers description.Copyright © 2016. All rights reserved.