BAEL2489 - Avoid check for null statement in Java (#6411)

* BAEL2489 - Avoid check for null statement in Java

* BAEL2489 Avoid check for null statement in Java

* BAEL2489 Avoid check for null statement in Java

* BAEL2489 Avoid check for null statement in Java

* BAEL2489 Avoid check for null statement in Java

* BAEL2489 Avoid check for null statement in Java - Removing unused pom changes

* BAEL2489 Avoid check for null statement in Java - Removing unused pom changes

* Delete pom.xml

Removing unused changes in core-java

* BAEL2489 Avoid check for null statement in Java - Removing unused pom changes
This commit is contained in:
dev-chirag
2019-03-29 06:26:15 +05:30
committed by KevinGilmore
parent 580ed9f626
commit 9687c88abf
16 changed files with 419 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package com.baeldung.nulls;
import java.util.Optional;
public class UsingOptional {
public Optional<Object> process(boolean processed) {
String response = doSomething(processed);
if (response == null) {
return Optional.empty();
}
return Optional.of(response);
}
private String doSomething(boolean processed) {
if (processed) {
return "passed";
} else {
return null;
}
}
}