-
Type:
Enhancement
-
Resolution: Won't Fix
-
Priority:
P4
-
None
-
Affects Version/s: 8, 9
-
Component/s: core-libs
A DESCRIPTION OF THE REQUEST :
There is orElse(T), but it shall have an orNull() too.
JUSTIFICATION :
If a null value is ok, orElse(null) is the cheapest way today.
When doing annotation base null analysis, this is bad, because I cannot mark orElse as returning non-null.
When there would be orNull(), for null analysis i could annotate like this:
@NonNull T orElse( @NonNull T t )
@Nullable T orNull()
There is orElse(T), but it shall have an orNull() too.
JUSTIFICATION :
If a null value is ok, orElse(null) is the cheapest way today.
When doing annotation base null analysis, this is bad, because I cannot mark orElse as returning non-null.
When there would be orNull(), for null analysis i could annotate like this:
@NonNull T orElse( @NonNull T t )
@Nullable T orNull()
- duplicates
-
JDK-8378345 Add Optional.orNull() as convenience alternative to orElse(null)
-
- Closed
-
-
JDK-8378350 Add method orNull to Optional
-
- Closed
-