Apache Common Lang
maven依赖
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
使用
//判断评论内容是否为空或空串
if (StringUtils.isBlank(commentCreateDTO.getContent())){
return ResultDTO.errorOf(CustomizeErrorCode.COMMENT_IS_EMPTY);
}
这用等于
if (commentCreateDTO.getContent() == null || commentCreateDTO.getContent() == "")