
org.coode.oppl.utils.ArgCheck Maven / Gradle / Ivy
package org.coode.oppl.utils;
/** @author Luigi Iannone */
public class ArgCheck {
/** @param o
* o
* @param name
* name
* @param
* type
* @return the input, if not null, illegal argument exception otherwise */
public static T checkNotNull(T o, String name) {
if (o == null) {
throw new IllegalArgumentException(name + " cannot be null");
}
if (o instanceof Iterable) {
int i = 0;
for (Object obj : (Iterable>) o) {
if (obj == null) {
throw new IllegalArgumentException(name
+ " cannot contain nulls, but contains a null at position: "
+ i);
}
i++;
}
}
return o;
}
/** @param o
* o
* @param
* type
* @return the input, if not null, illegal argument exception otherwise */
public static T checkNotNull(T o) {
return checkNotNull(o, "the object");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy