Joutsen  v0.4.1
Static Public Member Functions | List of all members
Joutsen.System.Precondition Class Reference

A static class that can be used to easily check input values of a method. More...

Static Public Member Functions

static TValue CheckNotNull< TValue > (TValue value, String name=null)
 Checks if a value is null and throws an System.ArgumentNullException if it is. More...
 
static String CheckNotNullOrEmpty (String value, String name=null)
 Checks if a String value is null or an empty string and raises an System.ArgumentException if it is. More...
 
static String CheckNotNullOrWhiteSpace (String value, String name=null)
 Checks if a string argument is null or consists only out of invisible or white space characters. More...
 
static T CheckRange< T > (T value, T min, T max, String name=null)
 Checks if an argument value is between an upper and lower bound. More...
 
static T CheckUpperBound< T > (T value, T max, String name=null)
 Checks if an argument value is below an upper bound. More...
 
static T CheckLowerBound< T > (T value, T min, String name=null)
 Checks if an argument value exceeds a lower bound. More...
 

Detailed Description

A static class that can be used to easily check input values of a method.

Since
0.2.1

Member Function Documentation

◆ CheckLowerBound< T >()

static T Joutsen.System.Precondition.CheckLowerBound< T > ( value,
min,
String  name = null 
)
static

Checks if an argument value exceeds a lower bound.

Parameters
valuethe argument value to check
minthe lowest value that is allowed
namethe name of the argument that is tested
Returns
the argument value if it is within the bound of min
Exceptions
ArgumentOutOfRangeExceptionif the argument value is not within the bound of min
Since
0.4.0
Type Constraints
T :IComparable 

◆ CheckNotNull< TValue >()

static TValue Joutsen.System.Precondition.CheckNotNull< TValue > ( TValue  value,
String  name = null 
)
static

Checks if a value is null and throws an System.ArgumentNullException if it is.

Parameters
TValuethe type of the value that is checked
valuethe value that is checked
nameoptional, the name of the parameter that refers to the checked value
Returns
the input value if it is not null
Exceptions
System.ArgumentNullExceptionif value is null
Type Constraints
TValue :class 

◆ CheckNotNullOrEmpty()

static String Joutsen.System.Precondition.CheckNotNullOrEmpty ( String  value,
String  name = null 
)
static

Checks if a String value is null or an empty string and raises an System.ArgumentException if it is.

Parameters
valuethe value that is checked
nameoptional, the name of the parameter that refers to the checked value
Returns
the input value if it is not null or an empty string
Exceptions
System.ArgumentNullExceptionif value is null
System.ArgumentExceptionif value is an empty string

◆ CheckNotNullOrWhiteSpace()

static String Joutsen.System.Precondition.CheckNotNullOrWhiteSpace ( String  value,
String  name = null 
)
static

Checks if a string argument is null or consists only out of invisible or white space characters.

Parameters
valuethe string to check
namethe name of the argument that is tested
Returns
the string value if it does not only consist of white space characters or is null
Exceptions
ArgumentNullExceptionif the string is null
ArgumentExceptionif the string is empty or only contains of white space characters
Since
0.4.0

◆ CheckRange< T >()

static T Joutsen.System.Precondition.CheckRange< T > ( value,
min,
max,
String  name = null 
)
static

Checks if an argument value is between an upper and lower bound.

Parameters
valuethe argument value to check
minthe lowest value that is allowed
maxthe highest value that is allowed
namethe name of the argument that is tested
Returns
the argument value if it is within the range of min and max
Exceptions
ArgumentOutOfRangeExceptionif the argument value is not within the range of min and max
Since
0.4.0
Type Constraints
T :IComparable 

◆ CheckUpperBound< T >()

static T Joutsen.System.Precondition.CheckUpperBound< T > ( value,
max,
String  name = null 
)
static

Checks if an argument value is below an upper bound.

Parameters
valuethe argument value to check
maxthe highest value that is allowed
namethe name of the argument that is tested
Returns
the argument value if it is within the bound of max
Exceptions
ArgumentOutOfRangeExceptionif the argument value is not within the bound of max
Since
0.4.0
Type Constraints
T :IComparable