クラス ValidationResult
java.lang.Object
org.thinkit.framework.envali.result.ValidationResult
- すべての実装されたインタフェース:
Serializable
public final class ValidationResult extends Object implements Serializable
A data class that manages the results of validation by
Envali
.
Manages ErrorType.RECOVERABLE
and ErrorType.UNRECOVERABLE
business errors as a result of validation. Detected business errors are
managed on a per-entity basis implementing the ValidatableEntity
interface.
It provides the following features to operate comfortably with detected business errors.
Test for the presence of business errors on any entity that implementsValidatableEntity
.ValidationResult validationResult = Envali.validate(concreteValidatableEntity); * // Returns true if there is a error on any
ValidatableEntity
, otherwise false validationResult.hasError();
Get a business error of a specified entity that implementsValidatableEntity
.ValidationResult validationResult = Envali.validate(concreteValidatableEntity); * // Returns List<BusinessError> List<BusinessError> businessErrors = validationResult.getError(ConcreteValidatableEntity.class);
- 導入されたバージョン:
- 1.0.1
- 関連項目:
- 直列化された形式
-
メソッドの概要
修飾子とタイプ メソッド 説明 boolean
equals(Object o)
List<BusinessError>
getError(@NonNull Class<? extends ValidatableEntity> validatableEntity)
Returns the error list associated with thevalidatableEntity
passed as an argument.boolean
hasError()
Tests for the presence of any business error in the validation result.int
hashCode()
static ValidationResult
none()
Returns the new instance of emptyValidationResult
.static ValidationResult
of(@NonNull Map<Class<? extends ValidatableEntity>,List<BusinessError>> validationResult)
Returns the new instance ofValidationResult
based onvalidationResult
passed as an argument.String
toString()
-
メソッドの詳細
-
none
Returns the new instance of emptyValidationResult
.- 戻り値:
- The new instance of empty
ValidationResult
.
-
of
public static ValidationResult of(@NonNull @NonNull Map<Class<? extends ValidatableEntity>,List<BusinessError>> validationResult)Returns the new instance ofValidationResult
based onvalidationResult
passed as an argument.- パラメータ:
validationResult
- The validation result- 戻り値:
- The new instance of
ValidationResult
- 例外:
NullPointerException
- Ifnull
is passed as an argument
-
getError
public List<BusinessError> getError(@NonNull @NonNull Class<? extends ValidatableEntity> validatableEntity)Returns the error list associated with thevalidatableEntity
passed as an argument.This method returns immutable empty List created by
List.of()
if there is no error data associated withvalidatableEntity
.This method recursively searches the error data associated with the
validatableEntity
object passed as argument.- パラメータ:
validatableEntity
- The validatable entity- 戻り値:
- The error list associated with the
validatableEntity
passed as an argument if there is an error, otherwise immutable empty List created byList.of()
. - 例外:
NullPointerException
- Ifnull
is passed as an argument
-
hasError
public boolean hasError()Tests for the presence of any business error in the validation result.- 戻り値:
true
if there is any business error, otherwisefalse
-
toString
-
equals
-
hashCode
public int hashCode()
-