Set<String> (@Nullable Collection<String> words) { if (words == null || words.isEmpty()) { return null; } Set<String> result = new HashSet<>(); for (String word : words) { String transformed = transform(word); if (transformed != null) { result.add(transformed); } } return result; }