public final class Preconditions extends Object
Utility class for guava style pre-condition checks. Not an official part of the AppAuth API; only intended for internal use and no guarantees are given on source or binary compatibility for this class between versions of AppAuth.
| Modifier and Type | Method and Description |
|---|---|
static void |
checkArgument(boolean expression)
Ensures the truth of an expression involving one or more parameters to the calling method.
|
static void |
checkArgument(boolean expression,
Object errorMessage)
Ensures the truth of an expression involving one or more parameters to the calling method.
|
static void |
checkArgument(boolean expression,
String errorTemplate,
Object... params)
Ensures the truth of an expression involving one or more parameters to the calling method.
|
static <T extends Collection<?>> |
checkCollectionNotEmpty(T collection,
Object errorMessage)
Ensures that a collection is not null or empty.
|
static String |
checkNotEmpty(String str,
Object errorMessage)
Ensures that a string is not null or empty.
|
static <T> T |
checkNotNull(T reference)
Ensures that an object reference passed as a parameter to the calling method is not null.
|
static <T> T |
checkNotNull(T reference,
Object errorMessage)
Ensures that an object reference passed as a parameter to the calling method is not null.
|
static String |
checkNullOrNotEmpty(String str,
Object errorMessage)
Ensures that the string is either null, or a non-empty string.
|
public static <T> T checkNotNull(T reference)
Ensures that an object reference passed as a parameter to the calling method is not null.
reference - an object referenceNullPointerException - if reference is nullpublic static <T> T checkNotNull(T reference,
@Nullable
Object errorMessage)
Ensures that an object reference passed as a parameter to the calling method is not null.
reference - an object referenceerrorMessage - the exception message to use if the check fails; will be converted to a
string using String.valueOf(Object)NullPointerException - if reference is null@NonNull public static String checkNotEmpty(String str, @Nullable Object errorMessage)
Ensures that a string is not null or empty.
@NonNull public static <T extends Collection<?>> T checkCollectionNotEmpty(T collection, @Nullable Object errorMessage)
Ensures that a collection is not null or empty.
@NonNull public static String checkNullOrNotEmpty(String str, @Nullable Object errorMessage)
Ensures that the string is either null, or a non-empty string.
public static void checkArgument(boolean expression)
Ensures the truth of an expression involving one or more parameters to the calling method.
expression - a boolean expressionIllegalArgumentException - if expression is falsepublic static void checkArgument(boolean expression,
@Nullable
Object errorMessage)
Ensures the truth of an expression involving one or more parameters to the calling method.
expression - a boolean expressionerrorMessage - the exception message to use if the check fails; will be converted to a
string using String.valueOf(Object)IllegalArgumentException - if expression is falsepublic static void checkArgument(boolean expression,
@NonNull
String errorTemplate,
Object... params)
Ensures the truth of an expression involving one or more parameters to the calling method.
expression - a boolean expressionerrorTemplate - the exception message to use if the check fails; this is used
as the template for String.format.params - the parameters to the exception message.