Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Guava 中,如果我有Collection<T>- 在 Guava 中是否有任何现有功能可以让我轻松地将其转换为Collection<Optional<T>>?
Collection<T>
Collection<Optional<T>>
只有正常的方式:
return Collections.transform(collection, new Function<T, Optional<T>>() { public Optional<T> apply(T t) { return Optional.of(t); } }
..虽然用明确的、严格的结构可能会更好。