void (String[] wordsInMessage) { Stream.of(wordsInMessage) .map(new Func<caret>tion<String, Mood>() { @Override public Mood apply(String s) { return WORD_TO_MOOD.get(s); } }) .filter(mood -> mood != null) .collect(Collectors.toSet()); }