Reputation: 59
I don't know all capabilities of Stream API.
I have an AutoCompleteTextView
with custom adaptor,I made a method that know if entered data in AutoCompleteTextView
is from suggested data or not ,
Now I want rewrite it using Lightweight-Stream-API for using under api 24
method in java8
private boolean isFromSuggestedData(List<StoreCategory> list, final String nameEnglish){
return list.stream().anyMatch(item -> nameEnglish.equals(item.getNameEnglish()));
}
Upvotes: 3
Views: 178
Reputation: 216
You can use kotlin "any" function
private fun isFormSuggestedData(list: List<StoreCategory>, nameEnglish: String): Boolean = list.any { nameEnglish == it.nameEnglish }
Upvotes: 1