com.silverpeas.util
Class AssertArgument

java.lang.Object
  extended by com.silverpeas.util.AssertArgument

public final class AssertArgument
extends Object

AssertArgument 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 begining 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
AssertArgument()
           
 
Method Summary
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 assertNotNull(Object arg, String msg)
          Asserts the specified argument is not null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssertArgument

public AssertArgument()
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.

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.


Copyright © 2016 Silverpeas. All Rights Reserved.