public class ImmutableValidationResult extends Object implements ValidationResult
ValidationResult. It provides a series of static factory methods for creating a result
in which the validation succeeded (ok()), and for validations that failed (error(I18nMessage),
error(String) error(I18nMessage, ValidationErrorType) and error(String, ValidationErrorType)).| Constructor and Description |
|---|
ImmutableValidationResult(String message,
ValidationErrorType type,
boolean error) |
| Modifier and Type | Method and Description |
|---|---|
static ValidationResult |
error(org.mule.runtime.api.i18n.I18nMessage message)
Creates a new instance with the given
message and which isError() returns true, with error type
ValidationErrorType.VALIDATION. |
static ValidationResult |
error(org.mule.runtime.api.i18n.I18nMessage message,
ValidationErrorType type)
Creates a new instance with the given
message and which isError() returns true, with error type
type. |
static ValidationResult |
error(String message)
Creates a new instance with the given
message and which isError() returns true, with error type
ValidationErrorType.VALIDATION. |
static ValidationResult |
error(String message,
ValidationErrorType type)
Creates a new instance with the given
message and which isError() returns true, with error type
type. |
ValidationErrorType |
getErrorType()
Returns the error type associated to the result, if
ValidationResult.isError() is true. |
String |
getMessage()
Returns a message associated with the execution of the validation.
|
boolean |
isError()
Whether the validation has failed or not
|
static ValidationResult |
ok()
|
public ImmutableValidationResult(String message, ValidationErrorType type, boolean error)
public static ValidationResult error(String message)
message and which isError() returns true, with error type
ValidationErrorType.VALIDATION.message - a messageImmutableValidationResultpublic static ValidationResult error(String message, ValidationErrorType type)
message and which isError() returns true, with error type
type.message - a messagetype - an error typeImmutableValidationResultpublic static ValidationResult error(org.mule.runtime.api.i18n.I18nMessage message)
message and which isError() returns true, with error type
ValidationErrorType.VALIDATION.message - a messageImmutableValidationResultpublic static ValidationResult error(org.mule.runtime.api.i18n.I18nMessage message, ValidationErrorType type)
message and which isError() returns true, with error type
type.message - a messagetype - an error typeImmutableValidationResultpublic static ValidationResult ok()
ImmutableValidationResult without message and which isError() method returns false. Since
this class is immutable, the same instance is always returnedOKpublic String getMessage()
ValidationResult.isError() is true), then it will contain the reason why the error was generated. Otherwise, it might or
might not contain some additional consideration about the validation resultgetMessage in interface ValidationResultString or nullpublic ValidationErrorType getErrorType()
ValidationResult.isError() is true.getErrorType in interface ValidationResultValidationErrorType or null if there was no errorpublic boolean isError()
isError in interface ValidationResultfalse otherwiseCopyright © 2023 MuleSoft, Inc.. All rights reserved.