I have a method that takes List<String> locations as a parameter. I am populating a list of users in the same method based on a particular condition. Now what I want is, the user should be present in this locations. In short, the user is valid iff user's location is present in the list of locations provided. locations.
This is my current code:
primaryList.stream()
.filter(some_pattern_matching)[.MATCH THE LOCATION HERE]
.map(user -> user.getNames())
.collect(toList())
is there any way to say locations.contains(user -> user.getLocation()) OR
user -> user.getLocation().isPresentIn(locations) OR have locations converted into one more stream and then do matching?
This is my current code:
.filter(locations.stream().filter(loc -> loc.equalsIgnoreCase(s.getLocation())))
which of course does not compile.
boolean userIsValid = locations.contains(user.getLocation())? Is that what you want? If not, provide the method you want to implement, with its arguments, return type, and javadoc, because it's quite unclear.