I am looking to refactor how I have used a stream in some of my code. The first example is how I currently have done it. The second example is what im trying to make it lo
Use Collectors.toSet :
Collectors.toSet
Set<String> results = someDao.findByType(type) .stream() .map(ClassName::getValue) .collect(Collectors.toSet());