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()));
}
你可以使用kotlin“any”功能
private fun isFormSuggestedData(list: List<StoreCategory>, nameEnglish: String): Boolean = list.any { nameEnglish == it.nameEnglish }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.