Class ObjectUtil

    • Method Detail

      • requireNotEmpty

        public static String requireNotEmpty​(String obj,
                                             String errorText)
        Ensures that obj isn't null or an empty string.
        Parameters:
        obj - The parameter to check.
        errorText - The exception message.
        Throws:
        IllegalArgumentException - If obj is null or an empty string.
      • requireNotNull

        public static <T extends Exception> void requireNotNull​(Object obj,
                                                                Supplier<T> exceptionSupplier)
                                                         throws T extends Exception
        Ensures that obj isn't null.
        Parameters:
        obj - The parameter to check.
        exceptionSupplier - The supplier for the exception that is thrown if obj is null.
        Throws:
        T - If obj is null.
        T extends Exception
      • isEmptyCollectionOrMap

        public static boolean isEmptyCollectionOrMap​(Object obj)
        Checks is the object is a empty 'collection' or 'map'.
        Parameters:
        obj - the object that is checked
        Returns:
        true if the given object is a empty collection or an empty map, false otherwise
      • verifyParameterPresence

        public static void verifyParameterPresence​(String parameterName,
                                                   String parameter)
        Ensures that parameter isn't null or an empty string.
        Parameters:
        parameterName - The name of the parameter (to be used in exception message).
        parameter - The parameter to check.
        Throws:
        IllegalArgumentException - If parameter is null or an empty string.
      • verifyParameterPresence

        public static void verifyParameterPresence​(String parameterName,
                                                   Object parameter)
        Ensures that parameter isn't null.
        Parameters:
        parameterName - The name of the parameter (to be used in exception message).
        parameter - The parameter to check.
        Throws:
        NullPointerException - If parameter is null.