-
public final class PreconditionsSimple static methods to be called at the start of your own methods to verify correct arguments and state. Each method supports 2 flavors - one that will always throw a runtime exception, and a NoThrow version that will only throw an exception when in strict mode. We use the former for internal state checks, and the later to validate arguments passed to the SDK.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classPreconditions.NoThrowPreconditions checks that avoid throwing and exception in release mode. These versions returna boolean which the caller should check.
-
Field Summary
Fields Modifier and Type Field Description public final static StringEMPTY_ARGUMENTS
-
Method Summary
Modifier and Type Method Description static voidcheckArgument(boolean expression)Ensures the truth of an expression. static voidcheckArgument(boolean expression, String errorMessage)Ensures the truth of an expression, with an error message. static voidcheckArgument(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs)Ensures the truth of an expression, with an error message that takes arguments. static voidcheckState(boolean expression)Ensures the truth of an expression involving the state of the caller. static voidcheckState(boolean expression, String errorMessage)Ensures the truth of an expression involving the state of the caller, with an error message. static voidcheckState(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs)Ensures the truth of an expression involving the state of the caller, with an error messagethat takes arguments. static voidcheckNotNull(Object reference)Ensures that an object reference is not null. static voidcheckNotNull(Object reference, String errorMessage)Ensures that an object reference is not null, with an error message. static voidcheckNotNull(Object reference, String errorMessageTemplate, Array<Object> errorMessageArgs)Ensures that an object reference is not null, with an error message that takes arguments. static voidcheckUiThread()Ensures that the current thread is the UI thread. static voidcheckUiThread(String errorMessage)Ensures that the current thread is the UI thread, with an error message. static voidcheckUiThread(String errorMessageTemplate, Array<Object> errorMessageArgs)Ensures that the current thread is the UI thread, with an error message that takesarguments. -
-
Method Detail
-
checkArgument
static void checkArgument(boolean expression)
Ensures the truth of an expression.
-
checkArgument
static void checkArgument(boolean expression, String errorMessage)
Ensures the truth of an expression, with an error message.
-
checkArgument
static void checkArgument(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs)
Ensures the truth of an expression, with an error message that takes arguments.
-
checkState
static void checkState(boolean expression)
Ensures the truth of an expression involving the state of the caller.
-
checkState
static void checkState(boolean expression, String errorMessage)
Ensures the truth of an expression involving the state of the caller, with an error message.
-
checkState
static void checkState(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs)
Ensures the truth of an expression involving the state of the caller, with an error messagethat takes arguments.
-
checkNotNull
static void checkNotNull(Object reference)
Ensures that an object reference is not null.
-
checkNotNull
static void checkNotNull(Object reference, String errorMessage)
Ensures that an object reference is not null, with an error message.
-
checkNotNull
static void checkNotNull(Object reference, String errorMessageTemplate, Array<Object> errorMessageArgs)
Ensures that an object reference is not null, with an error message that takes arguments.
-
checkUiThread
static void checkUiThread()
Ensures that the current thread is the UI thread.
-
checkUiThread
static void checkUiThread(String errorMessage)
Ensures that the current thread is the UI thread, with an error message.
-
checkUiThread
static void checkUiThread(String errorMessageTemplate, Array<Object> errorMessageArgs)
Ensures that the current thread is the UI thread, with an error message that takesarguments.
-
-
-
-