Class Contracts
- java.lang.Object
-
- com.microsoft.cognitiveservices.speech.util.Contracts
-
public class Contracts extends Object
Contract helper
-
-
Constructor Summary
Constructors Constructor Description Contracts()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidlogErrorIfFail(long hr)Logs error if fail.static voidthrowIfDirectoryDoesNotExist(String directory, String message)Checks if the directory exists.static voidthrowIfFail(long hr)Checks if fail, throws an exception based on the error code or error message.static voidthrowIfFileDoesNotExist(String filename, String message)Checks if the filename exists.static voidthrowIfIllegalLanguage(String language, String message)Checks if the language is a valid identifier.static voidthrowIfIllegalSubscriptionKey(String subscription, String message)Checks if the subscription is a valid identifier.static voidthrowIfNull(long address, String message)Checks if the long address argument is zero, if yes, throws a NullPointerExceptionstatic voidthrowIfNull(Object obj, String message)Checks if the argument is null, if yes, throws a NullPointerExceptionstatic voidthrowIfNullOrWhitespace(String obj, String message)Checks if the argument is null or whitespace, if yes, throws a IllegalArgumentException or NullPointerException.static voidthrowIfStateIsTrue(Boolean condition, String message)Checks if the argument is false, if yes, throws a IllegalStateException
-
-
-
Method Detail
-
throwIfNull
public static void throwIfNull(Object obj, String message)
Checks if the argument is null, if yes, throws a NullPointerException- Parameters:
obj- The object to test for null.message- The error message in case obj is null.
-
throwIfNull
public static void throwIfNull(long address, String message)Checks if the long address argument is zero, if yes, throws a NullPointerException- Parameters:
address- The address to test for null.message- The error message in case address is null.
-
throwIfStateIsTrue
public static void throwIfStateIsTrue(Boolean condition, String message)
Checks if the argument is false, if yes, throws a IllegalStateException- Parameters:
condition- The condition to test.message- The error message in case condition is true.
-
throwIfNullOrWhitespace
public static void throwIfNullOrWhitespace(String obj, String message)
Checks if the argument is null or whitespace, if yes, throws a IllegalArgumentException or NullPointerException.- Parameters:
obj- The object to test for null.message- The error message in case obj is null.
-
throwIfIllegalLanguage
public static void throwIfIllegalLanguage(String language, String message)
Checks if the language is a valid identifier.- Parameters:
language- The language identifier to test, e.g. "en-US"message- The error message in case obj is null.
-
throwIfIllegalSubscriptionKey
public static void throwIfIllegalSubscriptionKey(String subscription, String message)
Checks if the subscription is a valid identifier.- Parameters:
subscription- The subscription key to test, usually in the form of a guidmessage- The error message in case obj is null.
-
throwIfFileDoesNotExist
public static void throwIfFileDoesNotExist(String filename, String message)
Checks if the filename exists.- Parameters:
filename- The filename to testmessage- The error message in case filename does not exist.
-
throwIfDirectoryDoesNotExist
public static void throwIfDirectoryDoesNotExist(String directory, String message)
Checks if the directory exists.- Parameters:
directory- The directory to testmessage- The error message in case directory does not exist.
-
throwIfFail
public static void throwIfFail(long hr)
Checks if fail, throws an exception based on the error code or error message.- Parameters:
hr- The error handle
-
logErrorIfFail
public static void logErrorIfFail(long hr)
Logs error if fail.- Parameters:
hr- The error handle
-
-