public class Misc
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ANDROID_RUNTIME |
Constructor and Description |
---|
Misc() |
Modifier and Type | Method and Description |
---|---|
static void |
checkArgument(boolean argCondition,
java.lang.String errorMessage)
Check an argument meets a condition and throw an IllegalArgumentException if it doesn't.
|
static void |
checkNotNull(java.lang.Object param,
java.lang.String errorMessagePrefix)
Check that a parameter is not null and throw IllegalArgumentException with a message of
errorMessagePrefix + " must not be null." if it is null, defaulting to "Parameter must not be
null.".
|
static void |
checkNotNullOrEmpty(java.lang.String param,
java.lang.String errorMessagePrefix)
Check that a string parameter is not null or empty and throw IllegalArgumentException with a
message of errorMessagePrefix + " must not be empty." if it is empty, defaulting to
"Parameter must not be empty".
|
static void |
checkState(boolean stateCheck,
java.lang.String errorMessage)
Check if a condition is true and throw an IllegalStateException with the given
errorMessage if it is not.
|
static java.lang.String |
createUUID() |
static byte[] |
getSha1(java.io.InputStream shaFis) |
static boolean |
isRunningOnAndroid() |
static boolean |
isStringNullOrEmpty(java.lang.String param) |
static java.lang.String |
join(java.lang.String separator,
java.util.Collection<java.lang.String> stringsToJoin)
Utility to join strings with a separator.
|
public static final java.lang.String ANDROID_RUNTIME
public static java.lang.String createUUID()
public static boolean isRunningOnAndroid()
public static byte[] getSha1(java.io.InputStream shaFis)
public static java.lang.String join(java.lang.String separator, java.util.Collection<java.lang.String> stringsToJoin)
separator
- the string to use to separate the entriesstringsToJoin
- the strings to join togetherpublic static void checkNotNull(java.lang.Object param, java.lang.String errorMessagePrefix) throws java.lang.NullPointerException
param
- the parameter to checkerrorMessagePrefix
- the prefix of the error message to use for the
IllegalArgumentException if the parameter was nulljava.lang.NullPointerException
- if the arg is null.public static void checkNotNullOrEmpty(java.lang.String param, java.lang.String errorMessagePrefix) throws java.lang.IllegalArgumentException
param
- the string to checkerrorMessagePrefix
- the prefix of the error message to use for the
IllegalArgumentException if the parameter was null or emptyjava.lang.IllegalArgumentException
- if the string is null or emptypublic static boolean isStringNullOrEmpty(java.lang.String param)
param
- the string to checkpublic static void checkArgument(boolean argCondition, java.lang.String errorMessage) throws java.lang.IllegalArgumentException
argCondition
- the condition to checkerrorMessage
- the error message to use in the IllegalArgumentExceptionjava.lang.IllegalArgumentException
- if the argCondition is falsepublic static void checkState(boolean stateCheck, java.lang.String errorMessage) throws java.lang.IllegalStateException
stateCheck
- the state condition to checkerrorMessage
- the error string to add to the IllegalStateExceptionjava.lang.IllegalStateException
- if the stateCheck is false