这对我来说似乎太棘手了,因为ImmutableSet
实例仅使用以下内容构建ImmutableSet.Builder
实例,未实现Collection
所以你不能只使用Collectors.toCollection(ImmutableSet::new)
or Collectors.toCollection(ImmutableSet.Builder::new)
.
现在它已内置到番石榴中,
不可变集#toImmutableSet https://google.github.io/guava/releases/22.0/api/docs/com/google/common/collect/ImmutableSet.html#toImmutableSet--
使用像,
something.stream().collect(ImmutableSet.toImmutableSet())
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)