Package org.silverpeas.core.util
Class ArgumentAssertion
- java.lang.Object
-
- org.silverpeas.core.util.ArgumentAssertion
-
public final class ArgumentAssertion extends Object
ArgumentAssertion gathers all of the assertion operations that can be used for for checking the arguments specified in method call are correct. If an assertion failed, then an IllegalArgumentException is thrown. Using a such class to check the arguments before any code execution in a method ensures at the beginning the published contract of a method is well satisfied. It permits to detect in an explicit way the violation of that contract and thus to fix it in a fast way. Without any argument checking, the violation detection could be done in a more or less deep stacktrace execution of the method and in an implicit way, so letting it difficult to identify and to fix it.
-
-
Constructor Summary
Constructors Constructor Description ArgumentAssertion()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
assertDefined(String arg, String msg)
Asserts the specified String argument is well defined, that is it is not null and not empty.static void
assertNotDefined(String arg, String msg)
Asserts the specified String argument is not defined, that is it is null or empty.static void
assertNotNull(Object arg, String msg)
Asserts the specified argument is not null.static void
assertTrue(boolean arg, String msg)
Asserts the specified argument is true.
-
-
-
Method Detail
-
assertDefined
public static void assertDefined(String arg, String msg)
Asserts the specified String argument is well defined, that is it is not null and not empty.- Parameters:
arg
- the argument to assert.msg
- the message to pass if the argument isn't well defined.
-
assertNotDefined
public static void assertNotDefined(String arg, String msg)
Asserts the specified String argument is not defined, that is it is null or empty.- Parameters:
arg
- the argument to assert.msg
- the message to pass if the argument isn't well verified.
-
assertNotNull
public static void assertNotNull(Object arg, String msg)
Asserts the specified argument is not null.- Parameters:
arg
- the argument to assert.msg
- the message to pass if the argument is null.
-
assertTrue
public static void assertTrue(boolean arg, String msg)
Asserts the specified argument is true.- Parameters:
arg
- the argument to assert.msg
- the message to pass if the argument is false.
-
-