Class ValidationUtil
java.lang.Object
jp.ecuacion.lib.core.util.ValidationUtil
Provides validation-related utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Set<jakarta.validation.ConstraintViolation<T>> validate(T object) Validates and returnsConstraintViolationif validation errors exist.static <T> Optional<MultipleAppException> validateThenReturn(T object) Validates and returnsMultipleAppExceptionif validation errors exist.static <T> Optional<MultipleAppException> validateThenReturn(T object, Boolean addsItemNameToMessage, PropertyFileUtil.Arg messagePrefix, PropertyFileUtil.Arg messagePostfix) Validates and returnsMultipleAppExceptionif validation errors exist.static <T> voidvalidateThenThrow(T object) Validates and throwsMultipleAppExceptionif validation errors exist.static <T> voidvalidateThenThrow(T object, Boolean addsItemNameToMessage, PropertyFileUtil.Arg messagePrefix, PropertyFileUtil.Arg messagePostfix) Validates and throwsMultipleAppExceptionif validation errors exist.
-
Method Details
-
validate
@Nonnull public static <T> Set<jakarta.validation.ConstraintViolation<T>> validate(@RequireNonnull T object) Validates and returnsConstraintViolationif 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:
-
validateThenThrow
Validates and throwsMultipleAppExceptionif 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 throwsMultipleAppExceptionif 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 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 public static <T> Optional<MultipleAppException> validateThenReturn(@RequireNonnull T object, @Nullable Boolean addsItemNameToMessage, @Nullable PropertyFileUtil.Arg messagePrefix, @Nullable PropertyFileUtil.Arg messagePostfix) Validates and returnsMultipleAppExceptionif validation errors exist.- 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.
-