Interface ValidationResult
- All Known Subinterfaces:
MergeValidationResult
- All Known Implementing Classes:
RestValidationResult
,SimpleMergeValidationResult
,SimpleValidationResult
-
Method Summary
Modifier and TypeMethodDescriptiondefault ServiceException
convertToServiceException
(@Nullable String errorMsg) Converts this validation result into aServiceException
without throwing.Returns an iterable of the errors (if any) stored in this result.boolean
Checks for allowedInReadOnlyMode status.boolean
Checks for authorization status.default boolean
Just a convenience method.default boolean
Checks for both: validity and authorization.default boolean
isValid()
Checks for validity.default ServiceException
Deprecated.default ServiceException
throwIfInvalid
(String msg) Deprecated.since 5.10 please usethrowIfNotSuccessful(String)
default void
Converts this validation result into aServiceException
and throws it.default void
Converts this validation result into aServiceException
and throws it.default void
throwIfNotValid
(String msg) Deprecated.since 5.10 please usethrowIfNotSuccessful(String)
-
Method Details
-
isAuthorized
boolean isAuthorized()Checks for authorization status. Does NOT imply thevalidity check
.- Returns:
true
if the current user is permitted to perform the execution that the validation is for,false
otherwise.- See Also:
-
isAllowedInReadOnlyMode
boolean isAllowedInReadOnlyMode()Checks for allowedInReadOnlyMode status. Does NOT imply thevalidity check
.- Returns:
true
if the current user is allowed to perform the execution in read-only mode that the validation is for,false
otherwise.- Since:
- 6.8.0
- See Also:
-
isValid
default boolean isValid()Checks for validity. Does NOT imply theauthorization check
.By contract implementations MUST return
false
if there are errors in this ValidationResult. Default implementation is usually enough.- Returns:
true
if there are no errors in this result,false
otherwise.- See Also:
-
getErrors
Iterable<ValidationError> getErrors()Returns an iterable of the errors (if any) stored in this result. By contract having any errors here MUST also result inisValid()
returningfalse
.Default implementation of
isValid()
is safe fornull
values. Be cautious about returningnull
if not using the default implementation forisValid()
.- Returns:
- an iterable of the errors stored in this result.
- See Also:
-
isSuccessful
default boolean isSuccessful()Checks for both: validity and authorization. If we would have any other boolean condition(s) here in the future, default implementation will also check for that one(s) as well.By contract implementations MUST return
true
only when all the possible ValidationResult checks aretrue
. Having any of the checks returnfalse
means this method should also returnfalse
.Default implementation is usually enough.
- Returns:
true
in case this validationResult is bothvalid
ANDauthorized
,false
otherwise- See Also:
-
isNotSuccessful
default boolean isNotSuccessful()Just a convenience method. Defaults to the negation ofisSuccessful()
By contract implementations MUST return negation of the
isSuccessful()
.- Returns:
- negation of
isSuccessful()
- See Also:
-
throwIfInvalid
Deprecated.since 5.10 please usethrowIfNotSuccessful(String)
Converts this validation result into aServiceException
and throws it. Checks for both:isValid()
andisAuthorized()
.Issues:
- Should always throw and never return anything, even though return type is declared.
- Method name suggests only validation check even though two checks are actually performed.
This method is deprecated since 5.10, please use
throwIfNotSuccessful(String)
- Returns:
- the exception that will be thrown
- Throws:
ServiceException
- See Also:
-
throwIfNotValid
Deprecated.since 5.10 please usethrowIfNotSuccessful(String)
Converts this validation result into aServiceException
and throws it. Checks for both:isValid()
andisAuthorized()
.Issues:
- Method name suggests only validation check even though two checks are actually performed.
This method is deprecated since 5.10, please use
throwIfNotSuccessful(String)
- Throws:
ServiceException
- See Also:
-
throwIfInvalid
Deprecated.since 5.10 please usethrowIfNotSuccessful()
Converts this validation result into an Exception and throws it. Should always throw and never return anything, even though return type is declared. Deprecated for that reason.First validation error will be used as message string
This method is deprecated since 5.10, please use
throwIfNotSuccessful()
- Returns:
- the exception that will be thrown
- Throws:
ServiceException
- See Also:
-
convertToServiceException
Converts this validation result into aServiceException
without throwing. Implementations of this method should reasonably analyze the internals of this ValidationResult and return appropriate subclass ofServiceException
which is most suitable for the case.This method is used internally in the default implementations of
throwIfNotSuccessful()
andthrowIfNotSuccessful(String)
- Parameters:
errorMsg
- message to put in the Exception returned- Returns:
- instance of appropriate
ServiceException
subclass. - See Also:
-
throwIfNotSuccessful
Converts this validation result into aServiceException
and throws it. By default provided string will be used as an exception message.By contract implementations MUST throw proper subclass of
ServiceException
whenisNotSuccessful()
.- Throws:
ServiceException
- See Also:
-
throwIfNotSuccessful
Converts this validation result into aServiceException
and throws it.By default first validation error (if any) will be used as an exception message.
By contract implementations MUST throw proper subclass of
ServiceException
whenisNotSuccessful()
.
-
throwIfNotSuccessful()