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 ValidationFailures.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @NotNull DefaultValidationResultUsed to indicated a valid result. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultValidationResult(@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.booleanisValid()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 benullwhich leads to using the validator's default severity)defaultResourceBundle- the default resourceBundle which is used to resolve themessageKeyif 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:ValidationResultTells if the validation was successful or not.- Specified by:
isValidin interfaceValidationResult- Returns:
truefor yes,falseotherwise
-
getFailures
Description copied from interface:ValidationResultIn case the validation failed (check theValidationResult.isValid()method), this method returns the failure's causes.- Specified by:
getFailuresin interfaceValidationResult- Returns:
- the validation's failures (never
null)
-