Skip to content

Commit 23beaa9

Browse files
author
Zihlu Wang
authored
Merge pull request #83 from onixbyte/release/3.2.0
Closes #82
2 parents f8bce22 + 5a036d6 commit 23beaa9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,24 @@ public static <T, C extends Collection<T>> List<C> chunk(
112112
return result;
113113
}
114114

115+
/**
116+
* Check if a collection is not null and not empty.
117+
*
118+
* @param collection the collection to check
119+
* @return {@code true} if the collection is not null and not empty, {@code false} otherwise
120+
*/
121+
public static boolean notEmpty(Collection<?> collection) {
122+
return Objects.nonNull(collection) && !collection.isEmpty();
123+
}
124+
125+
/**
126+
* Check if a collection is null or empty.
127+
*
128+
* @param collection the collection to check
129+
* @return {@code true} if the collection is null or empty, {@code false} otherwise
130+
*/
131+
public static boolean isEmpty(Collection<?> collection) {
132+
return Objects.isNull(collection) || collection.isEmpty();
133+
}
134+
115135
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# SOFTWARE.
2121
#
2222

23-
artefactVersion=3.1.0
23+
artefactVersion=3.2.0
2424
projectUrl=https://onixbyte.com/projects/onixbyte-toolbox
2525
projectGithubUrl=https://github.com/onixbyte/onixbyte-toolbox
2626
licenseName=MIT

0 commit comments

Comments
 (0)