org.mycore.common
Class MCRArgumentChecker

java.lang.Object
  extended by org.mycore.common.MCRArgumentChecker

Deprecated.

public abstract class MCRArgumentChecker
extends Object

This class provides some static utility methods for checking values of arguments and conditions. This can be used to ensure that a method is not invoked with null arguments, for example. Here is a sample usage, where an MCRUsageException is thrown when "name" is empty:

 public void sayHelloTo(String name) {
     MCRArgumentChecker.ensureNotEmpty(name, "name");
     System.out.println("Hello " + name);
 }
 


Constructor Summary
MCRArgumentChecker()
          Deprecated.  
 
Method Summary
static void ensureIsFalse(boolean expression, String message)
          Deprecated. Ensures that a given boolean expression is false, or throws an MCRUsageException with the error message provided otherwise.
static void ensureIsTrue(boolean expression, String message)
          Deprecated. Ensures that a given boolean expression is true, or throws an MCRUsageException with the error message provided otherwise.
static void ensureNotEmpty(String s, String argumentName)
          Deprecated. Ensures that a given String variable does not contain a null reference, or a String of length 0, or a String containing only blanks.
static void ensureNotNegative(double value, String argumentName)
          Deprecated. Ensures that a given numeric value is not negative.
static void ensureNotNull(Object o, String argumentName)
          Deprecated. Ensures that a given variable does not contain a null reference, or throws an MCRUsageException with an error message otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCRArgumentChecker

public MCRArgumentChecker()
Deprecated. 
Method Detail

ensureIsTrue

public static void ensureIsTrue(boolean expression,
                                String message)
Deprecated. 
Ensures that a given boolean expression is true, or throws an MCRUsageException with the error message provided otherwise.

Parameters:
expression - the boolean expression that should be true
message - the error message to be thrown when the expression is not true
Throws:
MCRUsageException - if the expression is not true

ensureIsFalse

public static void ensureIsFalse(boolean expression,
                                 String message)
Deprecated. 
Ensures that a given boolean expression is false, or throws an MCRUsageException with the error message provided otherwise.

Parameters:
expression - the boolean expression that should be false
message - the error message to be thrown when the expression is true
Throws:
MCRUsageException - if the expression is true

ensureNotNull

public static void ensureNotNull(Object o,
                                 String argumentName)
Deprecated. 
Ensures that a given variable does not contain a null reference, or throws an MCRUsageException with an error message otherwise.

Parameters:
o - the Object variable that must not contain a null reference
argumentName - the name of the argument variable that must not be null
Throws:
MCRUsageException - if o is null

ensureNotEmpty

public static void ensureNotEmpty(String s,
                                  String argumentName)
Deprecated. 
Ensures that a given String variable does not contain a null reference, or a String of length 0, or a String containing only blanks.

Parameters:
s - the String variable that must not be null of empty
argumentName - the name of the String argument
Throws:
MCRUsageException - if s is null or s.trim().length() is 0

ensureNotNegative

public static void ensureNotNegative(double value,
                                     String argumentName)
Deprecated. 
Ensures that a given numeric value is not negative.

Parameters:
value - the value that must not be negative
argumentName - the name of the number argument
Throws:
MCRUsageException - if value is negative