When using Optional<T>
with a nullable field, is it more idiomatic to have the setter take
- an
Optional<T>
or - just a
T
and then have it as follows?
public class Bar {
private Optional<T> foo;
public void setFoo(T foo) {
this.foo = Optional.<T>fromNullable(foo);
}
public Optional<T> getFoo() {
return foo;
}
}