How to compare members of a list of complex objects with Hamcrest?
<p>Let's say I have a <code>List&lt;A&gt;</code> where </p>

<pre><code>class A {
    private Integer val;
    private String name;
}
</code></pre>

<p>and in my test case I get this list, with uncertain size, and content. What I wish to do is to compare <code>val</code> field of two list elements that I know has to be in the list with given <code>name</code> fields;</p>

<pre><code>List&lt;A&gt; list = logic.getList();
assertThat(list, allOf(hasItems(hasProperty("name", equalTo("first")), 
                       hasItems(hasProperty("val", equalTo(***value from another member with name = "second"))));
</code></pre>

<p>How can I achieve this, or is this even possible with Hamcrest Matchers?</p>