我不明白为什么您不能使用
Objects.firstNonNull:
this.foos = ImmutableSet.copyOf(Objects.firstNonNull(foos, ImmutableSet.of()));
您可以使用静态导入保存某些类型的输入,如果您要这样做的话:
import static com.google.common.collect.ImmutableSet.copyOf;import static com.google.common.collect.ImmutableSet.of;// snip...this.foos = copyOf(Objects.firstNonNull(foos, of()));



