I need to do a series of null checks ( nested null-checks ) to get an array of strings like below
String[] test;
if(CollectionUtils.isNotEmpty(checkList)){
if(MapUtils.isNotEmpty(checkList.get(0))){
if(StringUtils.isNotBlank(checkList.get(0).get("filename"))){
test = checkList.get(0).get("filename").split("_");
}
}
}
Is there a better way, maybe using Java8 Optional, to perform these kind of nested checks? I unsuccessfully tried to use Optional with flatmap / map.