public static < T > Collector < T , Set < T > > toSet ( ) { return new Collector < T , Set < T > > ( ) { @ Override public Set < T > collect ( Stream < ? extends T > stream ) { return Sets . newHashSet ( stream . iterator ( ) ) ; } } ; }
Collect to hash set