public final class Preconditions extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
checkArgument(boolean expression,
String errorMessage)
Ensures the truth of an expression involving parameters to the calling method.
|
static void |
checkConfigured(Context context,
String message,
int... ids) |
static <T> T |
checkNotNull(T val,
String errorMessageTemplate,
Object... errorMessageArgs)
Ensures that the provided value is not null, and throws a
NullPointerException if it
is null, with a message constructed from the provided error template and arguments. |
static void |
checkUnset(Bundle b,
String message,
String... keys) |
static int |
checkValidStyle(Context context,
int styleId,
String errorMessageTemplate,
Object... errorMessageArguments)
Ensures that the provided identifier matches a known style resource, and throws an
IllegalArgumentException if the resource cannot be found, or is not a style resource, with a
message constructed from the provided error template and arguments. |
@NonNull
public static <T> T checkNotNull(@Nullable
T val,
@NonNull
String errorMessageTemplate,
@Nullable
Object... errorMessageArgs)
NullPointerException if it
is null, with a message constructed from the provided error template and arguments.@StyleRes
public static int checkValidStyle(@NonNull
Context context,
int styleId,
@NonNull
String errorMessageTemplate,
@Nullable
Object... errorMessageArguments)
IllegalArgumentException if the resource cannot be found, or is not a style resource, with a
message constructed from the provided error template and arguments.public static void checkUnset(@NonNull
Bundle b,
@Nullable
String message,
@NonNull
String... keys)
public static void checkConfigured(@NonNull
Context context,
@Nullable
String message,
@StringRes
int... ids)
public static void checkArgument(boolean expression,
String errorMessage)
expression - a boolean expressionerrorMessage - the exception message to use if the check failsIllegalArgumentException - if expression is false