org.apache.hivemind.util
Class Defense

java.lang.Object
  extended by org.apache.hivemind.util.Defense

public final class Defense
extends java.lang.Object

Simple utilities for defensive programming.

Since:
1.1
Author:
Howard M. Lewis Ship

Method Summary
static void fieldNotNull(java.lang.Object value, java.lang.String fieldName)
          Check for null field value when not allowed.
static void isAssignable(java.lang.Object parameter, java.lang.Class expectedType, java.lang.String parameterName)
          Check that a parameter is not null, and assignable to a particular type.
static void notNull(java.lang.Object parameter, java.lang.String parameterName)
          Check for null parameter when not allowed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

notNull

public static void notNull(java.lang.Object parameter,
                           java.lang.String parameterName)
Check for null parameter when not allowed.

Throws:
java.lang.NullPointerException - if parameter is null (the message indicates the name of the parameter).

fieldNotNull

public static void fieldNotNull(java.lang.Object value,
                                java.lang.String fieldName)
Check for null field value when not allowed.

Throws:
java.lang.NullPointerException - if field is null (the message indicates the name of the field).

isAssignable

public static void isAssignable(java.lang.Object parameter,
                                java.lang.Class expectedType,
                                java.lang.String parameterName)
Check that a parameter is not null, and assignable to a particular type.

Throws:
java.lang.ClassCastException - if not assignable (with a useable message)


Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.