org.xs4j.util.NonNullValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xmlslurper Show documentation
Show all versions of xmlslurper Show documentation
An attempt to port parsing capabilities offered by Groovy XMLSlurper into the Java world. The following is not planned to be accurate projection, instead the most useful functions will be implemented.
The newest version!
package org.xs4j.util;
import java.util.Map;
/**
* Created by mturski on 11/4/2016.
*/
public final class NonNullValidator {
public static final T requireNonNull(T obj) {
if (obj == null)
throw new NullPointerException();
return obj;
}
public static final T[] requireNonNull(T[] objs) {
if (objs == null)
throw new NullPointerException();
for (T obj : objs)
if (obj == null)
throw new NullPointerException();
return objs;
}
public static final Map requireNonNull(Map map) {
if (map == null)
throw new NullPointerException();
for (K key : map.keySet()) {
if (key == null)
throw new NullPointerException();
if (map.get(key) == null)
throw new NullPointerException();
}
return map;
}
}