标签:大量 option body 避免 user 判断 java 8 引入 class
if(user != null) {
UserInfo userInfo = user.getUserInfo();
if(userInfo != null) {
BodyInfo bodyInfo = userInfo.getBodyInfo();
if(bodyInfo != null) {
return bodyInfo.getDesc();
}
}
}
return null;
return Optional.ofNullable(user).map(User::getUserInfo)
.map(UserInfo::getBodyInfo).map(BodyInfo::getDesc).orElse(null);
标签:大量 option body 避免 user 判断 java 8 引入 class
原文地址:https://www.cnblogs.com/kunlingou/p/12180203.html