Class ValidationUtil

java.lang.Object
jp.ecuacion.lib.core.util.ValidationUtil

public class ValidationUtil extends Object
Provides validation-related utilities.
  • Method Details

    • validate

      @Nonnull public static <T> Set<ConstraintViolationBean<T>> validate(@RequireNonnull T object)
      Validates and returns Set<ConstraintViolationBean<T>>.

      It returns an empty set when no errors occur according to the specification of jakarta validation.

      Type Parameters:
      T - Any class
      Parameters:
      object - object to validate
      Returns:
      a set of ConstraintViolationBean, may be empty set when no validation errors exist.
    • validate

      @Nonnull public static <T> Set<ConstraintViolationBean<T>> validate(@RequireNonnull T object, Class<?>... groups)
      Validates and returns Set<ConstraintViolationBean<T>>.

      It returns an empty set when no errors occur according to the specification of jakarta validation.

      Type Parameters:
      T - Any class
      Parameters:
      object - object to validate
      groups - validation groups
      Returns:
      a set of ConstraintViolationBean, may be empty set when no validation errors exist.
    • validate

      @Nonnull public static <T> Set<ConstraintViolationBean<T>> validate(@RequireNonnull T object, @Nullable ValidationUtil.MessageParameterBean parameterBean)
      Validates and returns Set<ConstraintViolationBean<T>>.

      It returns an empty set when no errors occur according to the specification of jakarta validation.

      Type Parameters:
      T - Any class
      Parameters:
      object - object to validate
      parameterBean - See ValidationUtil.MessageParameterBean.
      Returns:
      a set of ConstraintViolationBean, may be empty set when no validation errors exist.
    • validate

      @Nonnull public static <T> Set<ConstraintViolationBean<T>> validate(@RequireNonnull T object, @Nullable ValidationUtil.MessageParameterBean parameterBean, Class<?>... groups)
      Validates and returns Set<ConstraintViolationBean<T>>.

      It returns an empty set when no errors occur according to the specification of jakarta validation.

      Type Parameters:
      T - Any class
      Parameters:
      object - object to validate
      parameterBean - See ValidationUtil.MessageParameterBean.
      groups - validation groups
      Returns:
      a set of ConstraintViolationBean, may be empty set when no validation errors exist.
    • validateThenThrow

      public static <T> void validateThenThrow(@RequireNonnull T object) throws ConstraintViolationBeanException
      Validates and throws ConstraintViolationBeanException if validation errors exist.
      Type Parameters:
      T - any class
      Parameters:
      object - object to validate
      Throws:
      ConstraintViolationBeanException - ConstraintViolationBeanException
    • validateThenThrow

      public static <T> void validateThenThrow(@RequireNonnull T object, Class<?>... groups) throws ConstraintViolationBeanException
      Validates and throws ConstraintViolationBeanException if validation errors exist.
      Type Parameters:
      T - any class
      Parameters:
      object - object to validate
      groups - validation groups
      Throws:
      ConstraintViolationBeanException - ConstraintViolationBeanException
    • validateThenThrow

      @Deprecated(since="14.26.0") public static <T> void validateThenThrow(@RequireNonnull T object, @Nullable Boolean addsItemNameToMessage, @Nullable PropertyFileUtil.Arg messagePrefix, @Nullable PropertyFileUtil.Arg messagePostfix) throws ConstraintViolationBeanException
      Deprecated.
      Validates and throws ConstraintViolationBeanException if validation errors exist.
      Type Parameters:
      T - any class
      Parameters:
      object - object to validate
      Throws:
      ConstraintViolationBeanException - ConstraintViolationBeanException
    • validateThenThrow

      public static <T> void validateThenThrow(@RequireNonnull T object, @Nullable ValidationUtil.MessageParameterBean parameterBean) throws ConstraintViolationBeanException
      Validates and throws ConstraintViolationBeanException if validation errors exist.
      Type Parameters:
      T - any class
      Parameters:
      object - object to validate
      parameterBean - See ValidationUtil.MessageParameterBean.
      Throws:
      ConstraintViolationBeanException - ConstraintViolationBeanException
    • validateThenThrow

      @Deprecated(since="14.26.0") public static <T> void validateThenThrow(@RequireNonnull T object, @Nullable Boolean addsItemNameToMessage, @Nullable PropertyFileUtil.Arg messagePrefix, @Nullable PropertyFileUtil.Arg messagePostfix, Class<?>... groups) throws ConstraintViolationBeanException
      Deprecated.
      Validates and throws ConstraintViolationBeanException if validation errors exist.
      Type Parameters:
      T - any class
      Parameters:
      object - object to validate
      Throws:
      ConstraintViolationBeanException - ConstraintViolationBeanException
    • validateThenThrow

      public static <T> void validateThenThrow(@RequireNonnull T object, @Nullable ValidationUtil.MessageParameterBean parameterBean, Class<?>... groups) throws ConstraintViolationBeanException
      Validates and throws ConstraintViolationBeanException if validation errors exist.
      Type Parameters:
      T - any class
      Parameters:
      object - object to validate
      parameterBean - See ValidationUtil.MessageParameterBean.
      groups - validation groups
      Throws:
      ConstraintViolationBeanException - ConstraintViolationBeanException
    • validateThenReturn

      @Nonnull @Deprecated(since="14.26.0") public static <T> Optional<MultipleAppException> validateThenReturn(@RequireNonnull T object)
      Deprecated.
      Validates and returns MultipleAppException if validation errors exist.
      Type Parameters:
      T - any class
      Parameters:
      object - object to validate
      Returns:
      MultipleAppException, may be null when no validation errors exist.
    • validateThenReturn

      @Nonnull @Deprecated(since="14.26.0") public static <T> Optional<MultipleAppException> validateThenReturn(@RequireNonnull T object, Class<?>... groups)
      Deprecated.
      Validates and returns MultipleAppException if validation errors exist.
      Type Parameters:
      T - any class
      Parameters:
      object - object to validate
      Returns:
      MultipleAppException, may be null when no validation errors exist.
    • validateThenReturn

      @Nonnull @Deprecated(since="14.26.0") public static <T> Optional<MultipleAppException> validateThenReturn(@RequireNonnull T object, @Nullable Boolean addsItemNameToMessage, @Nullable PropertyFileUtil.Arg messagePrefix, @Nullable PropertyFileUtil.Arg messagePostfix)
      Deprecated.
      Validates and returns MultipleAppException if validation errors exist.

      3 parameters are added to arguments in addition to object, which are meant to show understandable error messages for non-display-value-validations (like validations to uploaded excel files) when the message displaying setting designates messages are to be shown at the bottom of each item.
      Prefix and postfix are used to additional explanation for error messages, like "About the uploaded excel file, ".

      Type Parameters:
      T - any class
      Parameters:
      object - object to validate
      addsItemNameToMessage - you'll get message with itemName when true is specified. It may be null, which is equal to false.
      messagePrefix - Used when you want to put an additional message before the original message. It may be null, which means no messages added.
      messagePostfix - Used when you want to put an additional message after the original message. It may be null, which means no messages added.
      Returns:
      MultipleAppException, may be null when no validation errors exist.
    • validateThenReturn

      @Nonnull @Deprecated(since="14.26.0") public static <T> Optional<MultipleAppException> validateThenReturn(@RequireNonnull T object, Boolean addsItemNameToMessage, @Nullable PropertyFileUtil.Arg messagePrefix, @Nullable PropertyFileUtil.Arg messagePostfix, Class<?>... groups)
      Deprecated.
      Validates and returns MultipleAppException if validation errors exist.

      3 parameters are added to arguments in addition to object, which are meant to show understandable error messages for non-display-value-validations (like validations to uploaded excel files) when the message displaying setting designates messages are to be shown at the bottom of each item.
      Prefix and postfix are used to additional explanation for error messages, like "About the uploaded excel file, ".

      Type Parameters:
      T - any class
      Parameters:
      object - object to validate
      addsItemNameToMessage - you'll get message with itemName when true is specified. It may be null, which is equal to false.
      messagePrefix - Used when you want to put an additional message before the original message. It may be null, which means no messages added.
      messagePostfix - Used when you want to put an additional message after the original message. It may be null, which means no messages added.
      Returns:
      MultipleAppException, may be null when no validation errors exist.
    • messageParameters

      public static ValidationUtil.MessageParameterBean messageParameters()
      Constructs and returns ParameterBean.