public static class Validator.ValidationException extends RuntimeException implements Localizable
Validator.validate(Object).
This exception is Localizable, providing optional message code and arguments for validation message
localization.
ValidationException may act as a wrapper for multiple validation errors, accessible through getCauses()
method.
Localizable.Builder<B extends Localizable.Builder<B>>, Localizable.LocalizableBuilder, Localizable.LocalizationException| Constructor and Description |
|---|
ValidationException(Localizable message)
Constructor with
Localizable message |
ValidationException(String message)
Constructor with message
|
ValidationException(String message,
String messageCode,
Object... messageArguments)
Constructor with localized message
|
ValidationException(Validator.ValidationException... causes)
Constructor with causes
|
| Modifier and Type | Method and Description |
|---|---|
Validator.ValidationException[] |
getCauses()
Get the
Validator.ValidationExceptions that caused this exception. |
List<String> |
getLocalizedValidationMessages()
Get all the localized validation error messages carried by this validation exception.
|
Object[] |
getMessageArguments()
Optional arguments to use for message localization.
|
String |
getMessageCode()
Get the message code to use to obtain a localized message
|
List<Localizable> |
getValidationMessages()
Get all the validation error messages carried by this validation exception.
|
void |
setCauses(Validator.ValidationException[] causes)
Set the
Validator.ValidationExceptions that caused this exception |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringequals, getClass, hashCode, notify, notifyAll, wait, wait, waitbuilder, getMessagepublic ValidationException(String message)
message - Validation error messagepublic ValidationException(String message, String messageCode, Object... messageArguments)
message - Default validation error messagemessageCode - Validation error message codemessageArguments - Optional message localization argumentspublic ValidationException(Localizable message)
Localizable messagemessage - Validation error message (not null)public ValidationException(Validator.ValidationException... causes)
causes - One or more Validator.ValidationExceptions that caused this exceptionpublic String getMessageCode()
LocalizablegetMessageCode in interface Localizablepublic Object[] getMessageArguments()
Localizable
By default this method returns null. Override it to provide message localization arguments.
Arguments resolution process is dependend from concrete localization handler. For example, a predefined argument placeholder character may be used to define arguments substitution positions within the localized message.
getMessageArguments in interface Localizablenull if nonepublic Validator.ValidationException[] getCauses()
Validator.ValidationExceptions that caused this exception.null if nonepublic void setCauses(Validator.ValidationException[] causes)
Validator.ValidationExceptions that caused this exceptioncauses - the causes to setpublic List<Localizable> getValidationMessages()
public List<String> getLocalizedValidationMessages()
For successfull localization, a LocalizationContext must be available as context resource using
LocalizationContext.getCurrent() and must be localized.
Copyright © 2017 The Holon Platform. All rights reserved.