It's better to use less concrete types like Set<String> or Collection<String> here. (The following code should be independent on concrete implementation of collection to make it easy to change it later if necessary).