Post

Java Apache Commons를 이용하여 null 체크

1. String null 체크

1) dependency 추가

1
2
3
4
5
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.12.0</version>
</dependency>

2) 활용

1
2
if (StringUtils.isNotEmpty(param)) {
}

2. List null 체크

1) dependency 추가

1
2
3
4
5
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-collections4</artifactId>
    <version>4.4</version>
</dependency>

2) 활용

1
2
if (CollectionUtils.isEmpty(paramList)) {
}
This post is licensed under CC BY 4.0 by the author.