if(spec.getVolumeSpecs() == null || spec.getVolumeSpecs().size() ==0 || spec.getVolumeSpecs().get(0) == null || spec.getVolumeSpecs().get(0).getPrimaryStorageInventory() == null){
return;
}
if(spec.getVolumeSpecs() == null || spec.getVolumeSpecs().size() ==0 || spec.getVolumeSpecs().get(0) == null || spec.getVolumeSpecs().get(0).getPrimaryStorageInventory() == null){
return;
}
1
letitbesqzr May 9, 2017
前两个判断随便找个工具类:
spec.getVolumeSpecs() == null || spec.getVolumeSpecs().size() ==0 ->CollectionUtil.isEmpty(spec.getVolumeSpecs()) spec.getVolumeSpecs().get(0) == null 没有意义 spec.getVolumeSpecs().get(0).getPrimaryStorageInventory() == null 看你业务是否有这个必要 |
2
SoloCompany May 9, 2017 via iPhone
?语法糖的最佳使用场景
只不过 java 没有😏 |
3
Adia OP @SoloCompany 请问什么语言有?
|
4
Michaelssss May 15, 2017
。。。。。。。这个时候不就是自己写个 Utils 的最佳实践么。。。
|
5
UncleRiver May 17, 2017
|
6
sonyxperia May 18, 2017
写个通用的 util
抽取成一个方法 |