Class ValidationUtil
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classStores validation parameters. -
Method Summary
Modifier and TypeMethodDescriptionConstructs and returns ParameterBean.static <T> Set<ConstraintViolationBean<T>> validate(T object) Validates and returnsSet<ConstraintViolationBean<T>>.static <T> Set<ConstraintViolationBean<T>> Validates and returnsSet<ConstraintViolationBean<T>>.static <T> Set<ConstraintViolationBean<T>> validate(T object, ValidationUtil.MessageParameterBean parameterBean) Validates and returnsSet<ConstraintViolationBean<T>>.static <T> Set<ConstraintViolationBean<T>> validate(T object, ValidationUtil.MessageParameterBean parameterBean, Class<?>... groups) Validates and returnsSet<ConstraintViolationBean<T>>.static <T> Optional<MultipleAppException> validateThenReturn(T object) Deprecated.static <T> Optional<MultipleAppException> validateThenReturn(T object, Boolean addsItemNameToMessage, PropertyFileUtil.Arg messagePrefix, PropertyFileUtil.Arg messagePostfix) Deprecated.static <T> Optional<MultipleAppException> validateThenReturn(T object, Boolean addsItemNameToMessage, PropertyFileUtil.Arg messagePrefix, PropertyFileUtil.Arg messagePostfix, Class<?>... groups) Deprecated.static <T> Optional<MultipleAppException> validateThenReturn(T object, Class<?>... groups) Deprecated.static <T> voidvalidateThenThrow(T object) Validates and throwsConstraintViolationBeanExceptionif validation errors exist.static <T> voidvalidateThenThrow(T object, Boolean addsItemNameToMessage, PropertyFileUtil.Arg messagePrefix, PropertyFileUtil.Arg messagePostfix) Deprecated.static <T> voidvalidateThenThrow(T object, Boolean addsItemNameToMessage, PropertyFileUtil.Arg messagePrefix, PropertyFileUtil.Arg messagePostfix, Class<?>... groups) Deprecated.static <T> voidvalidateThenThrow(T object, Class<?>... groups) Validates and throwsConstraintViolationBeanExceptionif validation errors exist.static <T> voidvalidateThenThrow(T object, ValidationUtil.MessageParameterBean parameterBean) Validates and throwsConstraintViolationBeanExceptionif validation errors exist.static <T> voidvalidateThenThrow(T object, ValidationUtil.MessageParameterBean parameterBean, Class<?>... groups) Validates and throwsConstraintViolationBeanExceptionif validation errors exist.
-
Method Details
-
validate
Validates and returnsSet<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 returnsSet<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 validategroups- 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 returnsSet<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 validateparameterBean- SeeValidationUtil.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 returnsSet<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 validateparameterBean- SeeValidationUtil.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 throwsConstraintViolationBeanExceptionif 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 throwsConstraintViolationBeanExceptionif validation errors exist.- Type Parameters:
T- any class- Parameters:
object- object to validategroups- 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 throwsConstraintViolationBeanExceptionif 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 throwsConstraintViolationBeanExceptionif validation errors exist.- Type Parameters:
T- any class- Parameters:
object- object to validateparameterBean- SeeValidationUtil.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 throwsConstraintViolationBeanExceptionif 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 throwsConstraintViolationBeanExceptionif validation errors exist.- Type Parameters:
T- any class- Parameters:
object- object to validateparameterBean- SeeValidationUtil.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 returnsMultipleAppExceptionif 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 returnsMultipleAppExceptionif 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 returnsMultipleAppExceptionif 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 validateaddsItemNameToMessage- you'll get message with itemName whentrueis specified. It may benull, which is equal tofalse.messagePrefix- Used when you want to put an additional message before the original message. It may benull, which means no messages added.messagePostfix- Used when you want to put an additional message after the original message. It may benull, 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 returnsMultipleAppExceptionif 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 validateaddsItemNameToMessage- you'll get message with itemName whentrueis specified. It may benull, which is equal tofalse.messagePrefix- Used when you want to put an additional message before the original message. It may benull, which means no messages added.messagePostfix- Used when you want to put an additional message after the original message. It may benull, which means no messages added.- Returns:
- MultipleAppException, may be null when no validation errors exist.
-
messageParameters
Constructs and returns ParameterBean.
-