Package org.apache.sling.validation.spi.support

# 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:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final @NotNull DefaultValidationResult`
`VALID`
Used to indicated a valid result.

## Constructor Summary

Constructors
Constructor
Description
`DefaultValidationResult(@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 Type
Method
Description
`@NotNull List<ValidationFailure>`
`getFailures()`
In case the validation failed (check the `ValidationResult.isValid()` method), this method returns the failure's causes.
`boolean`
`isValid()`
Tells if the validation was successful or not.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### VALID

@NotNull public static final @NotNull DefaultValidationResult 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 via `MessageFormat.format(String, Object...)`.

Parameters:
  `validationContext` - the context from which to take the location, severity and default resource bundle
  `messageKey` - the message key used for looking up a value in the resource bundle given in `ValidationFailure.getMessage(java.util.ResourceBundle)`
  `messageArguments` - optional number of arguments being used in `MessageFormat.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 via `MessageFormat.format(String, Object...)`.

Parameters:
  `location` - the location
  `severity` - the severity of the embedded failure (may be `null` which leads to using the validator's default severity)
  `defaultResourceBundle` - the default resourceBundle which is used to resolve the `messageKey` if no other bundle is provided
  `messageKey` - the message key used for looking up a value in the resource bundle given in `ValidationFailure.getMessage(java.util.ResourceBundle)`
  `messageArguments` - optional number of arguments being used in `MessageFormat.format(String, Object...)`

### DefaultValidationResult

public DefaultValidationResult(ValidationFailure... failures)

## Method Details

### isValid

public boolean isValid()
Description copied from interface: `ValidationResult`
Tells if the validation was successful or not.

Specified by:
  `isValid` in interface `ValidationResult`
Returns:
  `true` for yes, `false` otherwise

### getFailures

@NotNull public @NotNull List<ValidationFailure> getFailures()
Description copied from interface: `ValidationResult`
In case the validation failed (check the `ValidationResult.isValid()` method), this method returns the failure's causes.

Specified by:
  `getFailures` in interface `ValidationResult`
Returns:
  the validation's failures (never `null`)