public interface ValidationResult extends Serializable
ValidationResult instances are created using the factory methods
ok()
and error(String)
, denoting success and failure
respectively.
Modifier and Type | Interface and Description |
---|---|
static class |
ValidationResult.SimpleValidationResult
Simple validation result implementation.
|
Modifier and Type | Method and Description |
---|---|
static ValidationResult |
create(String errorMessage,
ErrorLevel errorLevel)
Creates the validation result with the given
errorMessage and
errorLevel . |
static ValidationResult |
error(String errorMessage)
Creates the validation result which represent an error with the given
errorMessage . |
Optional<ErrorLevel> |
getErrorLevel()
Returns optional error level for this validation result.
|
String |
getErrorMessage()
Returns the result message.
|
default boolean |
isError()
Checks if the result denotes an error.
|
static ValidationResult |
ok()
Returns a successful result.
|
String getErrorMessage()
Throws an IllegalStateException
if the result represents success.
IllegalStateException
- if the result represents successOptional<ErrorLevel> getErrorLevel()
Note: By default ErrorLevel.INFO
and
ErrorLevel.WARNING
are not considered to be blocking the
validation and conversion chain.
isError()
default boolean isError()
Note: By default ErrorLevel.INFO
and
ErrorLevel.WARNING
are not considered to be errors.
true
if the result denotes an error,
false
otherwisestatic ValidationResult ok()
static ValidationResult error(String errorMessage)
errorMessage
.errorMessage
- error message, not null
errorMessage
NullPointerException
- if errorMessage
is nullstatic ValidationResult create(String errorMessage, ErrorLevel errorLevel)
errorMessage
and
errorLevel
. Results with ErrorLevel
of INFO
or
WARNING
are not errors by default.errorMessage
- error message, not null
errorLevel
- error level, not null
errorMessage
and
errorLevel
NullPointerException
- if errorMessage
or errorLevel
is null
ok()
,
error(String)
Copyright © 2021. All rights reserved.