Package com.mongodb.assertions
Class Assertions
-
- com.mongodb.assertions.Assertions
-
public final class Assertions extends
Design by contract assertions.
This class is not part of the public API and may be removed or changed at any time.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
name, <?> collection)
Throw IllegalArgumentException if the collection contains a null value.static void
name, boolean condition)
Throw IllegalStateException if the condition if false.static void
name, boolean condition, SingleResultCallback<?> callback)
Throw IllegalStateException if the condition if false.static void
name, boolean condition)
Throw IllegalArgumentException if the condition if false.static <T> T
name, T value)
Throw IllegalArgumentException if the value is null.static <T> T
name, T value, SingleResultCallback<?> callback)
Throw IllegalArgumentException if the value is null.
-
-
-
Method Detail
-
notNull
public static <T> T notNull( name, T value)
Throw IllegalArgumentException if the value is null.- Type Parameters:
T
- the value type- Parameters:
name
- the parameter namevalue
- the value that should not be null- Returns:
- the value
- Throws:
- if value is null
-
notNull
public static <T> T notNull( name, T value, SingleResultCallback<?> callback)
Throw IllegalArgumentException if the value is null.- Type Parameters:
T
- the value type- Parameters:
name
- the parameter namevalue
- the value that should not be nullcallback
- the callback that also is passed the exception if the value is null- Returns:
- the value
- Throws:
- if value is null
-
isTrue
public static void isTrue( name, boolean condition)
Throw IllegalStateException if the condition if false.- Parameters:
name
- the name of the state that is being checkedcondition
- the condition about the parameter to check- Throws:
- if the condition is false
-
isTrue
public static void isTrue( name, boolean condition, SingleResultCallback<?> callback)
Throw IllegalStateException if the condition if false.- Parameters:
name
- the name of the state that is being checkedcondition
- the condition about the parameter to checkcallback
- the callback that also is passed the exception if the condition is not true- Throws:
- if the condition is false
-
isTrueArgument
public static void isTrueArgument( name, boolean condition)
Throw IllegalArgumentException if the condition if false.- Parameters:
name
- the name of the state that is being checkedcondition
- the condition about the parameter to check- Throws:
- if the condition is false
-
doesNotContainNull
public static void doesNotContainNull( name, <?> collection)
Throw IllegalArgumentException if the collection contains a null value.- Parameters:
name
- the name of the collectioncollection
- the collection- Throws:
- if the collection contains a null value
-
-