|
|
|
|
|
by grdvnl
4807 days ago
|
|
The Optional<T> in Guava just forces one to explicitly check for null and then get the container object during development. A typical pattern would be: Given an object a of type Optional<MyObject>, we write: if (a.isPresent()){
MyObject o = a.get()
} Of course, I could still do a.get() without evaluating isPresent() and end up with an java.lang.IllegalStateException. Here, we are "reminded" to do the null check. |
|