Class ParamValidatorUtil


  • public class ParamValidatorUtil
    extends Object
    Utility for function parameter validation.
    Since:
    2.3.0
    Author:
    attila.kiss
    • Method Detail

      • requireNonNull

        public static <T> T requireNonNull​(T object,
                                           String paramName)
                                    throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Ensures that the specified parameter cannot be null.
        Type Parameters:
        T - the type of the parameter
        Parameters:
        object - the parameter
        paramName - the name of the parameter
        Returns:
        the not null parameter
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if the parameter is null
      • requireNonBlank

        public static String requireNonBlank​(String object,
                                             String paramName)
                                      throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Ensures that the specified parameter cannot be blank String.
        Parameters:
        object - the parameter
        paramName - the name of the parameter
        Returns:
        the non blank parameter
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if the parameter is blank
      • requireNonEmpty

        public static <T> T requireNonEmpty​(Optional<T> object,
                                            String paramName)
                                     throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Ensures that the specified parameter cannot be an empty Optional.
        Type Parameters:
        T - the type of the parameter
        Parameters:
        object - the parameter
        paramName - the name of the parameter
        Returns:
        the value of the non-empty Optional
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if the parameter is null or empty
      • requireNonEmpty

        public static <T> Collection<T> requireNonEmpty​(Collection<T> object,
                                                        String paramName)
                                                 throws hu.icellmobilsoft.coffee.dto.exception.BaseException
        Ensures that the specified parameter cannot be an empty Collection.
        Type Parameters:
        T - the type of the Collection parameter
        Parameters:
        object - the parameter
        paramName - the name of the parameter
        Returns:
        the non-empty Collection
        Throws:
        hu.icellmobilsoft.coffee.dto.exception.BaseException - if the parameter is null or empty