-
public final class Preconditions.NoThrowPreconditions checks that avoid throwing and exception in release mode. These versions returna boolean which the caller should check.
-
-
Method Summary
Modifier and Type Method Description static voidsetStrictMode(boolean strictMode)Enables or disables strict mode.In strict mode, this class will throw anyway. static booleancheckArgument(boolean expression)Ensures the truth of an expression. static booleancheckArgument(boolean expression, String errorMessage)Ensures the truth of an expression, with an error message. static booleancheckArgument(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs)Ensures the truth of an expression, with an error message that takes arguments. static booleancheckState(boolean expression)Ensures the truth of an expression involving the state of the caller. static booleancheckState(boolean expression, String errorMessage)Ensures the truth of an expression involving the state of the caller, with an errormessage. static booleancheckState(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs)Ensures the truth of an expression involving the state of the caller, with an errormessage that takes arguments. static booleancheckNotNull(Object reference)Ensures that an object reference is not null. static booleancheckNotNull(Object reference, String errorMessage)Ensures that an object reference is not null, with an error message. static booleancheckNotNull(Object reference, String errorMessageTemplate, Array<Object> errorMessageArgs)Ensures that an object reference is not null, with an error message that takesarguments. static booleancheckUiThread()Ensures that the current thread is the UI thread. static booleancheckUiThread(String errorMessage)Ensures that the current thread is the UI thread, with an error message. static booleancheckUiThread(String errorMessageTemplate, Array<Object> errorMessageArgs)Ensures that the current thread is the UI thread, with an error message that takesarguments. -
-
Method Detail
-
setStrictMode
static void setStrictMode(boolean strictMode)
Enables or disables strict mode.In strict mode, this class will throw anyway. For example, you could set strict mode toBuildConfig.DEBUG to always get exceptions when in the IDE.
- Parameters:
strictMode- Whether to use strict mode.
-
checkArgument
static boolean checkArgument(boolean expression)
Ensures the truth of an expression.
-
checkArgument
static boolean checkArgument(boolean expression, String errorMessage)
Ensures the truth of an expression, with an error message.
-
checkArgument
static boolean checkArgument(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs)
Ensures the truth of an expression, with an error message that takes arguments.
-
checkState
static boolean checkState(boolean expression)
Ensures the truth of an expression involving the state of the caller.
-
checkState
static boolean checkState(boolean expression, String errorMessage)
Ensures the truth of an expression involving the state of the caller, with an errormessage.
-
checkState
static boolean checkState(boolean expression, String errorMessageTemplate, Array<Object> errorMessageArgs)
Ensures the truth of an expression involving the state of the caller, with an errormessage that takes arguments.
-
checkNotNull
static boolean checkNotNull(Object reference)
Ensures that an object reference is not null.
-
checkNotNull
static boolean checkNotNull(Object reference, String errorMessage)
Ensures that an object reference is not null, with an error message.
-
checkNotNull
static boolean checkNotNull(Object reference, String errorMessageTemplate, Array<Object> errorMessageArgs)
Ensures that an object reference is not null, with an error message that takesarguments.
-
checkUiThread
static boolean checkUiThread()
Ensures that the current thread is the UI thread.
-
checkUiThread
static boolean checkUiThread(String errorMessage)
Ensures that the current thread is the UI thread, with an error message.
-
checkUiThread
static boolean checkUiThread(String errorMessageTemplate, Array<Object> errorMessageArgs)
Ensures that the current thread is the UI thread, with an error message that takesarguments.
-
-
-
-