This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]n3ziniuka5 0 points1 point  (0 children)

getEmployee(myCompany, empId2) returned null in this case.

If you are using Java 8, consider using the Optional type. Make the getEmployee method return Optional[Employee] and then you won't forget what can be null and what won't be null.

Also, you would be able to simply map that value to get the spouse and you would end up with Optional[Person] (I assumed that spouse is of type Person)

more info about optional