我有一組貨幣,Set<String>和RequiredCurrency為Set<String>。我必須檢查所需的貨幣是否以貨幣設(shè)置存在。我已經(jīng)BiPredicate為以下內(nèi)容寫過文章,并嘗試在中使用相同的內(nèi)容anyMatch()。但這對(duì)我不起作用。我怎樣才能做到這一點(diǎn)。Set<String> currencyValues = currencies.getCurrencies().values() .stream() .map(currencyEntity -> { return currencyEntity.getNameOfSymbol(); }).collect(Collectors.toSet());Set<String> requestCurrencyCodes = globalPricingRequests.stream().map(globalPricingRequest -> { return globalPricingRequest.getCurrencyISOCode();}).collect(Collectors.toSet());BiPredicate<Set<String>, String> checkIfCurrencyPresent = Set::contains;boolean isCurrencyCodeValid = requestCurrencyCodes.stream().anyMatch(checkIfCurrencyPresent.test(currencyValues));我無法在中傳遞requestCurrencyCode checkIfCurrencyPresent.test(currencyValues)。
如何將BiPredicate與anyMatch()結(jié)合使用
動(dòng)漫人物
2021-04-06 13:09:52