@ExperimentalApi
public interface ValidationResult
| Modifier and Type | Method and Description |
|---|---|
default ServiceException |
convertToServiceException(@Nullable String errorMsg)
Converts this validation result into a
ServiceException without throwing. |
Iterable<ValidationError> |
getErrors()
Returns an iterable of the errors (if any) stored in this result.
|
boolean |
isAllowedInReadOnlyMode()
Checks for allowedInReadOnlyMode status.
|
boolean |
isAuthorized()
Checks for authorization status.
|
default boolean |
isNotSuccessful()
Just a convenience method.
|
default boolean |
isSuccessful()
Checks for both: validity and authorization.
|
default boolean |
isValid()
Checks for validity.
|
default ServiceException |
throwIfInvalid()
Deprecated.
since 5.10 please use
throwIfNotSuccessful() |
default ServiceException |
throwIfInvalid(String msg)
Deprecated.
since 5.10 please use
throwIfNotSuccessful(String) |
default void |
throwIfNotSuccessful()
Converts this validation result into a
ServiceException and throws it. |
default void |
throwIfNotSuccessful(String msg)
Converts this validation result into a
ServiceException and throws it. |
default void |
throwIfNotValid(String msg)
Deprecated.
since 5.10 please use
throwIfNotSuccessful(String) |
boolean isAuthorized()
validity check.true if the current user is permitted to perform the execution that the validation is for, false otherwise.isValid(),
isSuccessful()boolean isAllowedInReadOnlyMode()
validity check.true if the current user is allowed to perform the execution in read-only mode that the validation is for, false otherwise.isValid(),
isSuccessful()default boolean isValid()
authorization check.
By contract implementations MUST return false if there are errors in this ValidationResult.
Default implementation is usually enough.
true if there are no errors in this result, false otherwise.getErrors(),
isAuthorized(),
isSuccessful()Iterable<ValidationError> getErrors()
isValid() returning false.
Default implementation of isValid() is safe for null values.
Be cautious about returning null if not using the default implementation for isValid().
isValid(),
ValidationErrordefault boolean isSuccessful()
By contract implementations MUST return true only when all the possible ValidationResult checks are true.
Having any of the checks return false means this method should also return false.
Default implementation is usually enough.
true in case this validationResult is both valid AND authorized, false otherwiseisValid(),
isAuthorized()default boolean isNotSuccessful()
isSuccessful()
By contract implementations MUST return negation of the isSuccessful().
isSuccessful()isSuccessful()@Deprecated default ServiceException throwIfInvalid(String msg) throws ServiceException
throwIfNotSuccessful(String)ServiceException and throws it.
Checks for both: isValid() and isAuthorized().
Issues:
This method is deprecated since 5.10, please use throwIfNotSuccessful(String)
ServiceExceptionthrowIfNotSuccessful(String)@Deprecated default void throwIfNotValid(String msg) throws ServiceException
throwIfNotSuccessful(String)ServiceException and throws it.
Checks for both: isValid() and isAuthorized().
Issues:
This method is deprecated since 5.10, please use throwIfNotSuccessful(String)
ServiceExceptionthrowIfNotSuccessful(String)@Deprecated default ServiceException throwIfInvalid() throws ServiceException
throwIfNotSuccessful()First validation error will be used as message string
This method is deprecated since 5.10, please use throwIfNotSuccessful()
ServiceExceptionthrowIfNotSuccessful()default ServiceException convertToServiceException(@Nullable String errorMsg)
ServiceException without throwing.
Implementations of this method should reasonably analyze the internals of this ValidationResult
and return appropriate subclass of ServiceException which is most suitable for the case.
This method is used internally in the default implementations of throwIfNotSuccessful() and throwIfNotSuccessful(String)
errorMsg - message to put in the Exception returnedServiceException subclass.throwIfNotSuccessful(),
throwIfNotSuccessful(String)default void throwIfNotSuccessful(String msg) throws ServiceException
ServiceException and throws it.
By default provided string will be used as an exception message.
By contract implementations MUST throw proper subclass of ServiceException when isNotSuccessful().
ServiceExceptionisNotSuccessful(),
convertToServiceException(String)default void throwIfNotSuccessful()
throws ServiceException
ServiceException 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 when isNotSuccessful().
ServiceExceptionisNotSuccessful(),
convertToServiceException(String),
getErrors(),
ValidationErrorCopyright © 2003–2023 Atlassian. All rights reserved.