Use Optional.fromNullable to handle null pointers.