-
public final class PreconditionsPrecondition checking utility methods.
-
-
Method Summary
Modifier and Type Method Description static <T> TcheckNotNull(@Nullable() T val, @NonNull() String errorMessageTemplate, @Nullable() Array<Object> errorMessageArgs)Ensures that the provided value is not null, and throws a NullPointerException if itis null, with a message constructed from the provided error template and arguments. static intcheckValidStyle(@NonNull() Context context, int styleId, @NonNull() String errorMessageTemplate, @Nullable() Array<Object> errorMessageArguments)Ensures that the provided identifier matches a known style resource, and throws an if the resource cannot be found, or is not a style resource, with amessage constructed from the provided error template and arguments. static voidcheckUnset(@NonNull() Bundle b, @Nullable() String message, @NonNull() Array<String> keys)static voidcheckConfigured(@NonNull() Context context, @Nullable() String message, @StringRes() Array<int> ids)static voidcheckArgument(boolean expression, String errorMessage)Ensures the truth of an expression involving parameters to the calling method. -
-
Method Detail
-
checkNotNull
@NonNull() static <T> T checkNotNull(@Nullable() T val, @NonNull() String errorMessageTemplate, @Nullable() Array<Object> errorMessageArgs)
Ensures that the provided value is not null, and throws a NullPointerException if itis null, with a message constructed from the provided error template and arguments.
-
checkValidStyle
@StyleRes() static int checkValidStyle(@NonNull() Context context, int styleId, @NonNull() String errorMessageTemplate, @Nullable() Array<Object> errorMessageArguments)
Ensures that the provided identifier matches a known style resource, and throws an if the resource cannot be found, or is not a style resource, with amessage constructed from the provided error template and arguments.
-
checkUnset
@RestrictTo(value = RestrictTo.Scope.LIBRARY_GROUP) static void checkUnset(@NonNull() Bundle b, @Nullable() String message, @NonNull() Array<String> keys)
-
checkConfigured
@RestrictTo(value = RestrictTo.Scope.LIBRARY_GROUP) static void checkConfigured(@NonNull() Context context, @Nullable() String message, @StringRes() Array<int> ids)
-
checkArgument
static void checkArgument(boolean expression, String errorMessage)
Ensures the truth of an expression involving parameters to the calling method.
- Parameters:
expression- a boolean expressionerrorMessage- the exception message to use if the check fails
-
-
-
-