1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-22 20:47:57 +01:00

Merge pull request #252 from vanitasvitae/requireNonNullOrEmpty

Add Objects.requireNonNullOrEmpty
This commit is contained in:
Florian Schmaus 2018-07-17 11:59:06 +02:00 committed by GitHub
commit cf2b3ef634
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smack.util;
import java.util.Collection;
public class Objects {
public static <T> T requireNonNull(T obj, String message) {
@ -29,6 +31,13 @@ public class Objects {
return requireNonNull(obj, null);
}
public static <T extends Collection<?>> T requireNonNullOrEmpty(T collection, String message) {
if (requireNonNull(collection).isEmpty()) {
throw new IllegalArgumentException(message);
}
return collection;
}
public static boolean equals(Object a, Object b) {
return a == b || (a != null && a.equals(b));
}