@ProviderType public final class DefaultValidationFailure extends java.lang.Object implements ValidationFailure, java.io.Serializable
ResourceBundle
), messageArguments (being used with MessageFormat.format(String, Object...)
and the location where the validation failure occurred.Constructor and Description |
---|
DefaultValidationFailure(java.lang.String location,
int severity,
java.util.ResourceBundle defaultResourceBundle,
java.lang.String messageKey,
java.lang.Object... messageArguments)
Constructor of a validation failure.
|
DefaultValidationFailure(ValidatorContext validationContext,
java.lang.String messageKey,
java.lang.Object... messageArguments)
Constructor of a validation failure.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getLocation()
Returns the relative location of the property/resource/value which triggered this validation failure.
|
java.lang.String |
getMessage(java.util.ResourceBundle resourceBundle) |
int |
getSeverity() |
int |
hashCode() |
java.lang.String |
toString() |
public DefaultValidationFailure(@Nonnull ValidatorContext validationContext, @Nonnull java.lang.String messageKey, java.lang.Object... messageArguments)
validationContext
- the context from which to extract location, severity and default resource bundlemessageKey
- the key to look up in the resource bundlemessageArguments
- the arguments to be used with the looked up value from the resource bundle (given in getMessage(ResourceBundle)
public DefaultValidationFailure(@Nonnull java.lang.String location, int severity, @Nonnull java.util.ResourceBundle defaultResourceBundle, @Nonnull java.lang.String messageKey, java.lang.Object... messageArguments)
location
- the location where the validation error occurredseverity
- the severity of this failure (may be null
which leads to using the validator's default severity)defaultResourceBundle
- the default resourceBundle which is used to resolve the messageKey
in getMessage(ResourceBundle)
if null
is provided as parameter.messageKey
- the key to look up in the resource bundlemessageArguments
- the arguments to be used with the looked up value from the resource bundle (given in getMessage(ResourceBundle)
@Nonnull public java.lang.String getMessage(java.util.ResourceBundle resourceBundle)
getMessage
in interface ValidationFailure
resourceBundle
- ResourceBundle in which to look up the according message (used for i18n), if null
is given, the default resource bundle is used.@Nonnull public java.lang.String getLocation()
ValidationFailure
ValidationService.validate(org.apache.sling.api.resource.Resource, org.apache.sling.validation.model.ValidationModel)
or ValidationService.validateResourceRecursively(org.apache.sling.api.resource.Resource, boolean, java.util.function.Predicate, boolean)
orValidationService.validate(org.apache.sling.api.resource.ValueMap, org.apache.sling.validation.model.ValidationModel)
getLocation
in interface ValidationFailure
public int getSeverity()
getSeverity
in interface ValidationFailure
0
.public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Copyright © 2018 The Apache Software Foundation. All rights reserved.