[java] Object null check

자바 객체 null 체크


Objects.isNull(객체)


객체가 null 이면 true,
null 이 아니면 false 를 반환한다.


for(PostVO postVO : postList) {
    ImageVO imageVO = imageService.doSelectMainImage(postVO);
    if(Objects.isNull(imageVO)) {
        //LOG.debug("************null****************");
        switch (postVO.getCategory()) {
        case "daily life": postVO.setThumbNail("/resources/image_source/markdown.png"); break;
        case "java": postVO.setThumbNail("/resources/image_source/java.png"); break;
        case "javascript": postVO.setThumbNail("/resources/image_source/javascript.png"); break;
        }
    LOG.debug("postVO.getThumbNail(): "+postVO.getThumbNail());
    } else {
        postVO.setThumbNail(imageVO.getPath()+imageVO.getSaveName());
    }
}

links

social