简体   繁体   中英

Rewrite java 8 method with Lightweight-Stream-API for using for api 21

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 , 调用需要API级别24(当前最小值为21)错误

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM