mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-29 07:22:07 +01:00
Add Objects.requireNonNullOrEmpty
This commit is contained in:
parent
8011ba96bb
commit
4afe573a68
1 changed files with 9 additions and 0 deletions
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack.util;
|
package org.jivesoftware.smack.util;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
public class Objects {
|
public class Objects {
|
||||||
|
|
||||||
public static <T> T requireNonNull(T obj, String message) {
|
public static <T> T requireNonNull(T obj, String message) {
|
||||||
|
@ -29,6 +31,13 @@ public class Objects {
|
||||||
return requireNonNull(obj, null);
|
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) {
|
public static boolean equals(Object a, Object b) {
|
||||||
return a == b || (a != null && a.equals(b));
|
return a == b || (a != null && a.equals(b));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue