Package com.mongodb.kafka.connect.util
Class Assertions
java.lang.Object
com.mongodb.kafka.connect.util.Assertions
All methods throw
AssertionError
and should be used to check conditions which may be
violated if and only if the driver code is incorrect. The intended usage of these methods is the
same as of the Java
assert
statement. The reason for not using the assert
statements is that they are
not always enabled. We prefer having internal checks always done at the cost of our code doing a
relatively small amount of additional work in production. The assert...
methods return
values to open possibilities of being used fluently.-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
assertFalse
(boolean value) static <T> T
assertNotNull
(T value) static <T> T
assertNull
(T value) static boolean
assertTrue
(boolean value) static AssertionError
fail()
static AssertionError
-
Method Details
-
assertNull
- Type Parameters:
T
- The type ofvalue
.- Parameters:
value
- A value to check.- Returns:
null
.- Throws:
AssertionError
- Ifvalue
is notnull
.
-
assertNotNull
- Type Parameters:
T
- The type ofvalue
.- Parameters:
value
- A value to check.- Returns:
value
- Throws:
AssertionError
- Ifvalue
isnull
.
-
assertTrue
- Parameters:
value
- A value to check.- Returns:
true
.- Throws:
AssertionError
- Ifvalue
isfalse
.
-
assertFalse
- Parameters:
value
- A value to check.- Returns:
false
.- Throws:
AssertionError
- Ifvalue
istrue
.
-
fail
- Returns:
- Never completes normally. The return type is
AssertionError
to allow writingthrow fail()
. This may be helpful in non-void
methods. - Throws:
AssertionError
- Always
-
fail
- Parameters:
msg
- The failure message.- Returns:
- Never completes normally. The return type is
AssertionError
to allow writingthrow fail("failure message")
. This may be helpful in non-void
methods. - Throws:
AssertionError
- Always
-