-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
I have many times run into code that follows this pattern:
if (variable.getValue() != null) {
set("foo", variable.GetValue());
}
It seems like this could be simplified with a new Objects method like "whenNonNull":
Objects.whenNonNull(variable.getValue(), (value) -> set("foo", value);
The new Objects class method would be something like:
static void whenNonNull (Object o, Consumer<T> consumer)
I wasn't entirely sure where to make this enhancement request as this definitely isn't large enough to be part of a JEP.
I have many times run into code that follows this pattern:
if (variable.getValue() != null) {
set("foo", variable.GetValue());
}
It seems like this could be simplified with a new Objects method like "whenNonNull":
Objects.whenNonNull(variable.getValue(), (value) -> set("foo", value);
The new Objects class method would be something like:
static void whenNonNull (Object o, Consumer<T> consumer)
I wasn't entirely sure where to make this enhancement request as this definitely isn't large enough to be part of a JEP.