Adventure at Umalu  22nd March, 2013
Rogue-like Dungeon Crawler, written in Java
 All Classes Functions Variables Pages
Static Public Member Functions | List of all members
jade.util.Guard Class Reference

Static Public Member Functions

static void argumentIsNotNull (Object argument)
 
static void argumentsAreNotNull (Object...arguments)
 
static void argumentIsPositive (int argument)
 
static void argumentsArePositive (int...arguments)
 
static void argumentIsNonNegative (int argument)
 
static void argumentsAreNonNegative (int...arguments)
 
static void argumentInsideBound (int argument, int max)
 
static void argumentsInsideBounds (int x, int y, int width, int height)
 
static void verifyState (boolean condition)
 
static void validateArgument (boolean condition)
 
static< T > T returnNonNull (T value)
 

Detailed Description

A collection of methods meant to help check method preconditions and postconditions.

Member Function Documentation

static void jade.util.Guard.argumentInsideBound ( int  argument,
int  max 
)
static

Throws an

IndexOutOfBoundsException

if the supplied bound is not between 0 (inclusive) and max (exclusive).

Parameters
argumentthe argument being tested
maxthe upper bound (exclusive) of the argument
static void jade.util.Guard.argumentIsNonNegative ( int  argument)
static

Throws an

IllegalArgumentException

if the supplied argument is negative integer. In other words, the argument must be in the set {0, 1, 2,3, ...}, or the set of all positive integers.

Parameters
argumentthe argument being tested
static void jade.util.Guard.argumentIsNotNull ( Object  argument)
static

Throws an

IllegalArgumentException

if the supplied argument is null.

Parameters
argumentthe argument being tested
static void jade.util.Guard.argumentIsPositive ( int  argument)
static

Throws an

IllegalArgumentException

if the supplied argument is not a positive integer. In other words, the argument must be in the set {1, 2,3, ...}, or the set of all natural numbers.

Parameters
argumentthe argument being tested
static void jade.util.Guard.argumentsAreNonNegative ( int...  arguments)
static

Throws an

IllegalArgumentException

if any of the supplied arguments are a negative integer. In other words, each argument must be in the set {0, 1, 2,3, ...}, or the set of all positive integer.

Parameters
argumentsthe arguments being tested
static void jade.util.Guard.argumentsAreNotNull ( Object...  arguments)
static

Throws an

IllegalArgumentException

if any of the supplied arguments is null.

Parameters
argumentsthe arguments being tested
static void jade.util.Guard.argumentsArePositive ( int...  arguments)
static

Throws an

IllegalArgumentException

if any of the supplied arguments are not a positive integer. In other words, each argument must be in the set {1, 2,3, ...}, or the set of all natural numbers.

Parameters
argumentsthe arguments being tested
static void jade.util.Guard.argumentsInsideBounds ( int  x,
int  y,
int  width,
int  height 
)
static

Throws an

IndexOutOfBoundsException

if the supplied (x, y) coordinate is not between inside the given bounds. In other words, x and y must be non-negative integers, with x less than width, and y less than height.

Parameters
xthe x location being tested
ythe y location being tested
widththe upper bound (exclusive) of x
heightthe upper bound (exclusive) of y.
static <T> T jade.util.Guard.returnNonNull ( value)
static

Returns the given return value if it is not null. Otherwise, an

IllegalStateException

is thrown. The typical usage would be as the return statement in another method (eg

return Guard.returnNonNull(value);

).

Parameters
<T>the type of the value being tested for non-null
valuethe value being returned and tested for non-null
Returns
value, if value is not null
static void jade.util.Guard.validateArgument ( boolean  condition)
static

Throws an

IllegalArgumentException

if the given condition is not true.

Parameters
conditionthe state being tested
static void jade.util.Guard.verifyState ( boolean  condition)
static

Throws an

IllegalStateException

if the given condition is not true.

Parameters
conditionthe state being tested

The documentation for this class was generated from the following file: