Package org.apache.ofbiz.base.util
Class Assert
java.lang.Object
org.apache.ofbiz.base.util.Assert
Basic assertions. The static methods in this class provide a convenient way
to test method arguments. All of the methods in this class throw
IllegalArgumentException
if the method arguments are invalid.-
Method Summary
Modifier and TypeMethodDescriptionstatic void
isAssignableTo
(String argumentName, Object argumentObject, Class<?> targetClass) Tests if an argument is not null and can be cast to a specified class.static void
isInstanceOf
(String argumentName, Object argumentObject, Class<?> targetClass) Tests if an argument is not null and is an instance of a specified class.static void
isInstanceOf
(String argumentName, Object argumentObject, Class<?>... targetClasses) Tests if an argument is not null and is an instance of one of the specified classes.static void
isNotInstanceOf
(String argumentName, Object argumentObject, Class<?> targetClass) Tests if an argument is not null and is not an instance of a specified class.static void
isNotInstanceOf
(String argumentName, Object argumentObject, Class<?>... targetClasses) Tests if an argument is not null and is not an instance of one of the specified classes.static void
Tests if an argument is not null and is not empty.static <T extends Map<?,
?>>
voidTests if an argument is not null and is not empty.static <T> void
Tests if an argument is not null and is not empty.static void
Tests a list of arguments fornull
.static void
Tests an argument fornull
.
-
Method Details
-
isAssignableTo
Tests if an argument is not null and can be cast to a specified class.Assert.isAssignableTo("foo", foo, Foo.class);
- Parameters:
argumentName
-argumentObject
-targetClass
-- Throws:
IllegalArgumentException
-
isInstanceOf
Tests if an argument is not null and is an instance of a specified class.Assert.isInstanceOf("foo", foo, Foo.class);
- Parameters:
argumentName
-argumentObject
-targetClass
-- Throws:
IllegalArgumentException
-
isInstanceOf
public static void isInstanceOf(String argumentName, Object argumentObject, Class<?>... targetClasses) Tests if an argument is not null and is an instance of one of the specified classes.Assert.isInstanceOf("foo", foo, Foo.class, Bar.class, ...);
- Parameters:
argumentName
-argumentObject
-targetClasses
-- Throws:
IllegalArgumentException
-
isNotInstanceOf
public static void isNotInstanceOf(String argumentName, Object argumentObject, Class<?> targetClass) Tests if an argument is not null and is not an instance of a specified class.Assert.isNotInstanceOf("foo", foo, Foo.class);
- Parameters:
argumentName
-argumentObject
-targetClass
-- Throws:
IllegalArgumentException
-
isNotInstanceOf
public static void isNotInstanceOf(String argumentName, Object argumentObject, Class<?>... targetClasses) Tests if an argument is not null and is not an instance of one of the specified classes.Assert.isNotInstanceOf("foo", foo, Foo.class, Bar.class, ...);
- Parameters:
argumentName
-argumentObject
-targetClasses
-- Throws:
IllegalArgumentException
-
notEmpty
Tests if an argument is not null and is not empty.Assert.notEmpty("foo", foo);
- Parameters:
argumentName
-argumentObject
-- Throws:
IllegalArgumentException
-
notEmpty
Tests if an argument is not null and is not empty.Assert.notEmpty("foo", foo);
- Parameters:
argumentName
-argumentObject
-- Throws:
IllegalArgumentException
-
notEmpty
Tests if an argument is not null and is not empty.Assert.notEmpty("foo", foo);
- Parameters:
argumentName
-argumentObject
-- Throws:
IllegalArgumentException
-
notEmpty
Tests if an argument is not null and is not empty.Assert.notEmpty("foo", foo);
- Parameters:
argumentName
-argumentObject
-- Throws:
IllegalArgumentException
-
notNull
Tests a list of arguments fornull
.Assert.notNull("foo", foo, "bar", bar, ...);
- Parameters:
arguments
-- Throws:
IllegalArgumentException
-
notNull
Tests an argument fornull
.Assert.notNull("foo", foo);
- Parameters:
argumentName
-objectToTest
-- Throws:
IllegalArgumentException
-