iaik.tc.utils.misc
Class CheckPrecondition

java.lang.Object
  extended by iaik.tc.utils.misc.CheckPrecondition

public class CheckPrecondition
extends java.lang.Object

This class contains methods that are used to check an validated parameters passed to methods.


Constructor Summary
CheckPrecondition()
           
 
Method Summary
static void equal(long input, long expected, java.lang.String argName)
          This method is used to ensure that a given parameter is not null.
static void gtOrEq(long input, java.lang.String argName, long lowerBound)
          This method is used to ensure that a given parameter is less than or equal to the given upper bound.
static void gtZero(long input, java.lang.String argName)
          This method is used to ensure that a given parameter is not null.
static void isInstanceOf(java.lang.Object objToCheck, java.lang.String objName, java.lang.Class exptectedType)
          This method is used to ensure that a given parameter is an instance of a given class.
static void ltOrEq(long input, java.lang.String argName, long upperBound)
          This method is used to ensure that a given parameter is less than or equal to the given upper bound.
static void notNegative(long input, java.lang.String argName)
          This method is used to ensure that a given parameter is not null.
static void notNull(java.lang.Object input, java.lang.String argName)
          This method is used to ensure that a given parameter is not null.
static void notNullAndInstanceOf(java.lang.Object objToCheck, java.lang.String objName, java.lang.Class exptectedType)
          This method first checks if objToCheck is not null and then checks if it is an instance of expectgedType.
static void optionalInstanceOf(java.lang.Object objToCheck, java.lang.String objName, java.lang.Class exptectedType)
          This method is a variation of isInstanceOf(Object, String, Class).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CheckPrecondition

public CheckPrecondition()
Method Detail

notNull

public static void notNull(java.lang.Object input,
                           java.lang.String argName)
                    throws java.lang.IllegalArgumentException
This method is used to ensure that a given parameter is not null.

Throws:
java.lang.IllegalArgumentException

notNegative

public static void notNegative(long input,
                               java.lang.String argName)
                        throws java.lang.IllegalArgumentException
This method is used to ensure that a given parameter is not null.

Throws:
java.lang.IllegalArgumentException

gtZero

public static void gtZero(long input,
                          java.lang.String argName)
                   throws java.lang.IllegalArgumentException
This method is used to ensure that a given parameter is not null.

Throws:
java.lang.IllegalArgumentException

ltOrEq

public static void ltOrEq(long input,
                          java.lang.String argName,
                          long upperBound)
                   throws java.lang.IllegalArgumentException
This method is used to ensure that a given parameter is less than or equal to the given upper bound.

Throws:
java.lang.IllegalArgumentException

gtOrEq

public static void gtOrEq(long input,
                          java.lang.String argName,
                          long lowerBound)
                   throws java.lang.IllegalArgumentException
This method is used to ensure that a given parameter is less than or equal to the given upper bound.

Throws:
java.lang.IllegalArgumentException

equal

public static void equal(long input,
                         long expected,
                         java.lang.String argName)
                  throws java.lang.IllegalArgumentException
This method is used to ensure that a given parameter is not null.

Throws:
java.lang.IllegalArgumentException

isInstanceOf

public static void isInstanceOf(java.lang.Object objToCheck,
                                java.lang.String objName,
                                java.lang.Class exptectedType)
This method is used to ensure that a given parameter is an instance of a given class. This is useful if the parameter of a method is specified in some generic form (e.g. Interface) but the actual implementation only works correctly if the supplied parameter is a specific implementation of the interface.


optionalInstanceOf

public static void optionalInstanceOf(java.lang.Object objToCheck,
                                      java.lang.String objName,
                                      java.lang.Class exptectedType)
This method is a variation of isInstanceOf(Object, String, Class). In contrast to the later, this method does not throw an exception is objToCheck is null. It can be used to check if optional parameters are of a specific type.


notNullAndInstanceOf

public static void notNullAndInstanceOf(java.lang.Object objToCheck,
                                        java.lang.String objName,
                                        java.lang.Class exptectedType)
This method first checks if objToCheck is not null and then checks if it is an instance of expectgedType. It effectively combines combines the methods notNull(Object, String) and isInstanceOf(Object, String, Class).