Map<String, Long> cardsMap = cards .stream() .collect(Collectors.groupingBy(Card::getCardValue, Collectors.counting()));