Class Contracts


  • public class Contracts
    extends Object
    Contract helper
    • Constructor Detail

      • Contracts

        public Contracts()
    • 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 guid
        message - 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 test
        message - 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 test
        message - 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