Packagecom.threerings.util
Classpublic class Preconditions

Utility functions for checking function parameters and throwing appropriate errors.



Public Methods
 MethodDefined by
  
checkArgument(expression:Boolean, message:String = null):void
[static] Check that the specified expression is true.
Preconditions
  
checkIndex(index:int, size:int, message:String = null):int
[static] Check that the specified index is valid: greater than or equal to 0, and less than size.
Preconditions
  
checkNotNull(ref:*, message:String = null):*
[static] Check that the reference is not null (or undefined) and return it as a convenience.
Preconditions
  
checkRange(value:Number, low:Number, high:Number, message:String = null):Number
[static] Check that the specified value is not NaN and between the low and high values (inclusive).
Preconditions
Method detail
checkArgument()method
public static function checkArgument(expression:Boolean, message:String = null):void

Check that the specified expression is true.

Parameters
expression:Boolean
 
message:String (default = null)

Throws
checkIndex()method 
public static function checkIndex(index:int, size:int, message:String = null):int

Check that the specified index is valid: greater than or equal to 0, and less than size.

Parameters
index:int
 
size:int
 
message:String (default = null)

Returns
int — the index that was checked.

Throws
checkNotNull()method 
public static function checkNotNull(ref:*, message:String = null):*

Check that the reference is not null (or undefined) and return it as a convenience.

Parameters
ref:*
 
message:String (default = null)

Returns
* — the reference that was checked.

Throws
checkRange()method 
public static function checkRange(value:Number, low:Number, high:Number, message:String = null):Number

Check that the specified value is not NaN and between the low and high values (inclusive). Passing NaN for low or high will disable that test.

Parameters
value:Number
 
low:Number
 
high:Number
 
message:String (default = null)

Returns
Number — the value that was checked.

Throws