Class ArgUtils
java.lang.Object
org.apache.juneau.common.internal.ArgUtils
Method argument utility methods.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final void
Throws anIllegalArgumentException
if the specified expression isfalse .static final <T> T
assertArgNotNull
(String name, T o) Throws anIllegalArgumentException
if the specified argument isnull .static final <E> Class<E>[]
assertClassArrayArgIsType
(String name, Class<E> type, Class<?>[] value) Throws anIllegalArgumentException
if the specified value doesn't have all subclasses of the specified type.
-
Constructor Details
-
ArgUtils
public ArgUtils()
-
-
Method Details
-
assertArgNotNull
Throws anIllegalArgumentException
if 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 anIllegalArgumentException
if 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 anIllegalArgumentException
if 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.
-