0

I would like to use lambdaJ for selecting specific values from list,

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

I want it to select values LIKE given string, with this example it is working fine, but only if the word is "michael" it won't recognize "Michael", is there any way to do this with LambdaJ?

iie
  • 501
  • 4
  • 8
  • 26

2 Answers2

2

You can try it as follows;

List<someFriends> newFriends = select(firendsCollection,having(on(someFriends.class).getDescription(),     Matchers.containsString(("michael")).and(Matchers.containsString(("Michael")))));
dursun
  • 1,861
  • 2
  • 21
  • 38
1

Please refer to this question click here.

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

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

equalToIgnoringCase() returns a Matcher. Therefore, we cannot use it in containsString method.

Community
  • 1
  • 1
Kiwi
  • 374
  • 5
  • 11
  • its arguing about this part Matchers.containsString(equalToIgnoringCase... IntelliJ says to write something like this: Matchers.containsString(String.valueOf( – iie May 29 '13 at 08:53
  • I move the equalToIgnoringCase out. Please try the revised one. – Kiwi May 29 '13 at 09:04
  • I change containsString to contains, so that the parameter type is compatible with equalToIgnoringCase(). Hope this will work. – Kiwi May 29 '13 at 09:33
  • well it didn't = (, contains doesn't appear to be in Matchers, but I found other solution: http://svn.assembla.com/svn/efor-integracion-ws/codigo/trunk/integracion/ws/src/main/java/es/efor/integracion/matchers/StringContainsIgnoreCase.java – iie May 29 '13 at 09:52