Class ArgUtils
java.lang.Object
org.apache.juneau.commons.internal.ArgUtils
Method argument utility methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final voidThrows anIllegalArgumentExceptionif the specified expression isfalse .static final <T> TassertArgNotNull(String name, T o) Throws anIllegalArgumentExceptionif the specified argument isnull .static final <E> Class<E>[]assertClassArrayArgIsType(String name, Class<E> type, Class<?>[] value) Throws anIllegalArgumentExceptionif the specified value doesn't have all subclasses of the specified type.
-
Constructor Details
-
ArgUtils
public ArgUtils()
-
-
Method Details
-
assertArgNotNull
Throws anIllegalArgumentExceptionif the specified argument isnull .Example:
import static org.apache.juneau.internal.ArgUtils.*;public String setFoo(Stringfoo ) {assertArgNotNull ("foo" ,foo ); ... }- Type Parameters:
T- The argument data type.- Parameters:
name- The argument name.o- The object to check.- Returns:
- The same argument.
- Throws:
IllegalArgumentException- Constructed exception.
-
assertArg
public static final void assertArg(boolean expression, String msg, Object... args) throws IllegalArgumentException Throws anIllegalArgumentExceptionif the specified expression isfalse .Example:
import static org.apache.juneau.internal.ArgUtils.*;public String setFoo(List<String>foo ) {assertArg (foo !=null && !foo .isEmpty(),"'foo' cannot be null or empty." ); ... }- Parameters:
expression- The boolean expression to check.msg- The exception message.args- The exception message args.- Throws:
IllegalArgumentException- Constructed exception.
-
assertClassArrayArgIsType
public static final <E> Class<E>[] assertClassArrayArgIsType(String name, Class<E> type, Class<?>[] value) throws IllegalArgumentException Throws anIllegalArgumentExceptionif the specified value doesn't have all subclasses of the specified type.- Type Parameters:
E- The element type.- Parameters:
name- The argument name.type- The expected parent class.value- The array value being checked.- Returns:
- The value cast to the specified array type.
- Throws:
IllegalArgumentException- Constructed exception.
-