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<jakarta.validation.ConstraintViolation<T>> validate(@RequireNonnull T object)
      Validates and returns ConstraintViolation if validation errors exist.
      Type Parameters:
      T - any class
      Parameters:
      object - object to validate
      Returns:
      a Set of ConstraintViolation, may be null when no validation errors exist.
      See Also:
      • Validator
    • validateThenThrow

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

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

      @Nonnull public static <T> Optional<MultipleAppException> validateThenReturn(@RequireNonnull T object)
      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 public static <T> Optional<MultipleAppException> validateThenReturn(@RequireNonnull T object, @Nullable Boolean addsItemNameToMessage, @Nullable PropertyFileUtil.Arg messagePrefix, @Nullable PropertyFileUtil.Arg messagePostfix)
      Validates and returns MultipleAppException if validation errors exist.
      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.