Class DefaultValidationResult
java.lang.Object
org.apache.sling.validation.spi.support.DefaultValidationResult
- All Implemented Interfaces:
Serializable
,ValidationResult
@ProviderType
public final class DefaultValidationResult
extends Object
implements ValidationResult, Serializable
Default implementation of
ValidationResult
wrapping a list of ValidationFailure
s.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final @NotNull DefaultValidationResult
Used to indicated a valid result. -
Constructor Summary
ConstructorDescriptionDefaultValidationResult
(@NotNull String location, int severity, @NotNull ResourceBundle defaultResourceBundle, @NotNull String messageKey, Object... messageArguments) Constructs a result with one failure message.DefaultValidationResult
(@NotNull ValidatorContext validationContext, @NotNull String messageKey, Object... messageArguments) Constructs a result with one failure message.DefaultValidationResult
(ValidationFailure... failures) -
Method Summary
Modifier and TypeMethodDescription@NotNull List<ValidationFailure>
In case the validation failed (check theValidationResult.isValid()
method), this method returns the failure's causes.boolean
isValid()
Tells if the validation was successful or not.
-
Field Details
-
VALID
Used to indicated a valid result.
-
-
Constructor Details
-
DefaultValidationResult
public DefaultValidationResult(@NotNull @NotNull ValidatorContext validationContext, @NotNull @NotNull String messageKey, Object... messageArguments) Constructs a result with one failure message. The message is constructed by looking up the given messageKey from a resourceBundle. and formatting it using the given messageArguments viaMessageFormat.format(String, Object...)
.- Parameters:
validationContext
- the context from which to take the location, severity and default resource bundlemessageKey
- the message key used for looking up a value in the resource bundle given inValidationFailure.getMessage(java.util.ResourceBundle)
messageArguments
- optional number of arguments being used inMessageFormat.format(String, Object...)
-
DefaultValidationResult
public DefaultValidationResult(@NotNull @NotNull String location, int severity, @NotNull @NotNull ResourceBundle defaultResourceBundle, @NotNull @NotNull String messageKey, Object... messageArguments) Constructs a result with one failure message. The message is constructed by looking up the given messageKey from a resourceBundle. and formatting it using the given messageArguments viaMessageFormat.format(String, Object...)
.- Parameters:
location
- the locationseverity
- the severity of the embedded failure (may benull
which leads to using the validator's default severity)defaultResourceBundle
- the default resourceBundle which is used to resolve themessageKey
if no other bundle is providedmessageKey
- the message key used for looking up a value in the resource bundle given inValidationFailure.getMessage(java.util.ResourceBundle)
messageArguments
- optional number of arguments being used inMessageFormat.format(String, Object...)
-
DefaultValidationResult
-
-
Method Details
-
isValid
public boolean isValid()Description copied from interface:ValidationResult
Tells if the validation was successful or not.- Specified by:
isValid
in interfaceValidationResult
- Returns:
true
for yes,false
otherwise
-
getFailures
Description copied from interface:ValidationResult
In case the validation failed (check theValidationResult.isValid()
method), this method returns the failure's causes.- Specified by:
getFailures
in interfaceValidationResult
- Returns:
- the validation's failures (never
null
)
-