0

我想使用 lambdaJ 从列表中选择特定值,

List<someFriends> newFriends = select(firendsCollection,having(on(someFriends.class).getDescription(),     Matchers.containsString(("michael"))));

我希望它选择像给定字符串一样的值,在这个例子中它工作正常,但只有当单词是“michael”时它才会识别“Michael”,有没有办法用 LambdaJ 做到这一点?

4

2 回答 2

2

您可以尝试如下;

List<someFriends> newFriends = select(firendsCollection,having(on(someFriends.class).getDescription(),     Matchers.containsString(("michael")).and(Matchers.containsString(("Michael")))));
于 2013-05-29T10:38:07.230 回答
1

请参考这个问题点击这里

import static org.hamcrest.text.IsEqualIgnoringCase.equalToIgnoringCase;

List newFriends = select(firendsCollection,having(on(someFriends.class).getDescription(), Matchers.contains(equalToIgnoringCase("michael"))));

equalToIgnoringCase() 返回一个匹配器。因此,我们不能在 containsString 方法中使用它。

于 2013-05-29T08:28:04.877 回答