BAEL2489 Avoid check for null statement in Java - adding ofnullable to Optional example
This commit is contained in:
parent
4eb3c8567a
commit
6b104db2bb
@ -8,11 +8,7 @@ public class UsingOptional {
|
||||
|
||||
String response = doSomething(processed);
|
||||
|
||||
if (response == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
return Optional.of(response);
|
||||
return Optional.ofNullable(response);
|
||||
}
|
||||
|
||||
private String doSomething(boolean processed) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user