Wednesday, 12 September 2018
Tuesday, 11 September 2018
Java 8: Using optional with nested objects
I am writing this blog for demonstrating the usage of Optional class in java8, with nested objects.
Consider below the class structure,
Now consider that, you want to extract an email from the Employee object, also you have to avoid null pointer exception. In a traditional way, you have to write a lot of NULL conditions.
Check below code with an Optional class which simplifies your code structure.
I will write a few more posts for using an Optional with collection classes.
Consider below the class structure,
Now consider that, you want to extract an email from the Employee object, also you have to avoid null pointer exception. In a traditional way, you have to write a lot of NULL conditions.
Check below code with an Optional class which simplifies your code structure.
I will write a few more posts for using an Optional with collection classes.
Subscribe to:
Posts (Atom)
-
SQL injection attack is one of the old attack. I found it interesting so giving short description on it. It is mainly related with web site...
-
Semaphore provides simple and effective way of controlling multiple threads trying to access same resource. This concepts was invented by d...
-
Repository architectural style is data centered style, which allows user interaction for data processing. This style shows two main entitie...


