org.fuin.objects4j
Class Contract

java.lang.Object
  extended by org.fuin.objects4j.Contract

public final class Contract
extends java.lang.Object

Utility class for assertions on objects.


Method Summary
static void requireArgNotNull(java.lang.String name, java.lang.Object value)
          Checks if the value is not null.
static
<T> void
requireValid(T value)
          Checks if the given value is valid and throws an IllegalArgumentException otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

requireArgNotNull

public static void requireArgNotNull(java.lang.String name,
                                     java.lang.Object value)
                              throws ContractViolationException
Checks if the value is not null.

Parameters:
name - Name of the value for a possible error message.
value - Value to check.
Throws:
ContractViolationException - The value was null.

requireValid

public static <T> void requireValid(T value)
                         throws ContractViolationException
Checks if the given value is valid and throws an IllegalArgumentException otherwise.

Type Parameters:
T - Type of the argument.
Parameters:
value - Value to check.
Throws:
ContractViolationException - The value is invalid.


Copyright © 2010 Future Invent Informationsmanagement GmbH. All Rights Reserved.