Re: Filtering based on a nested collection

44 views
Skip to first unread message

Mark Richards

unread,
Oct 31, 2012, 5:51:56 PM10/31/12
to lam...@googlegroups.com
Sorry, it wasn't a Lambdaj question. I got this working by implementing a custom hamcrest matcher that just iterated through the elements in the collection and returned true if it found at least one match. Thanks.


On Tuesday, October 9, 2012 2:50:11 PM UTC+13, Mark Richards wrote:
Hi,

Sorry, I did look around before posting the question.

Say I have a Person object with a nickNameList. I wanna return all person objects such that a person's nickname is at least one of what I pass in a List.

I tried this. but this doesn't work, it doesn't find a match.

        List<String> inputList = Arrays.asList(new String[]{"Dog1", "Dog2"});
        List<Person> resultList = select(personList, having(on(Person.class).getNickNameList(), Matchers.hasItem(inputList)));


I also tried creating Matchers.anyof using each item in the inputList, that wouldn't work either. Am I missing something that is obvious?

Thanks for your help.


Reply all
Reply to author
Forward
0 new messages