Created
June 12, 2018 13:35
-
-
Save pramoth/3cd35ef8da84a3c0296adfde2cb9f9cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package th.co.geniustree.demo; | |
| import org.junit.Test; | |
| public class OptionalTest { | |
| @Test | |
| public void no_optional() { | |
| Home home = findHomeFromSomeWhere(); | |
| //print cc. of a car in my home | |
| if (home != null) { | |
| Car car = home.getCar(); | |
| if (car != null) { | |
| Engine engine = car.getEngine(); | |
| if (engine != null) { | |
| Piston piston = engine.getPiston(); | |
| System.out.println(piston.getCapacity()); | |
| } | |
| } | |
| } | |
| } | |
| private Home findHomeFromSomeWhere() { | |
| return new Home(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment