Is it possible to document that return value is not null
with Java Optional
?
Most tools and frameworks care only about arguments but I'd like to express in type that return value is not null
(instead of doing that in JavaDoc).
UPDATE Looks like you can agree with team to use Optional
as return value if you want to express possible null
and direct object when it is definitely not null:
public Optional<Job> getJob() { ... }
public Job extractJob(NonNullJobHolder<Job> holder) { ... }