public class SimpleMergeValidationResult extends Object implements MergeValidationResult
Modifier and Type | Class and Description |
---|---|
static class |
SimpleMergeValidationResult.Builder |
Constructor and Description |
---|
SimpleMergeValidationResult(SimpleMergeValidationResult.Builder builder) |
Modifier and Type | Method and Description |
---|---|
static SimpleMergeValidationResult.Builder |
builder(ValidationResult result) |
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.
|
boolean |
isValid()
Checks for validity.
|
ServiceException |
throwIfInvalid()
Deprecated.
since 5.10 please use
throwIfNotSuccessful() |
ServiceException |
throwIfInvalid(String msg)
Deprecated.
since 5.10 please use
throwIfNotSuccessful(String) |
void |
throwIfNotSuccessful()
Converts this validation result into a
ServiceException and throws it. |
void |
throwIfNotSuccessful(String msg)
Converts this validation result into a
ServiceException and throws it. |
void |
throwIfNotValid(String msg)
Deprecated.
since 5.10 please use
throwIfNotSuccessful(String) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isNotSuccessful, isSuccessful
public SimpleMergeValidationResult(SimpleMergeValidationResult.Builder builder)
public boolean isAuthorized()
ValidationResult
validity check
.isAuthorized
in interface ValidationResult
true
if the current user is permitted to perform the execution that the validation is for, false
otherwise.ValidationResult.isValid()
,
ValidationResult.isSuccessful()
public boolean isAllowedInReadOnlyMode()
ValidationResult
validity check
.isAllowedInReadOnlyMode
in interface ValidationResult
true
if the current user is allowed to perform the execution in read-only mode that the validation is for, false
otherwise.ValidationResult.isValid()
,
ValidationResult.isSuccessful()
public boolean isValid()
ValidationResult
authorization check
.
By contract implementations MUST return false
if there are errors in this ValidationResult.
Default implementation is usually enough.
isValid
in interface ValidationResult
true
if there are no errors in this result, false
otherwise.ValidationResult.getErrors()
,
ValidationResult.isAuthorized()
,
ValidationResult.isSuccessful()
public Iterable<ValidationError> getErrors()
ValidationResult
ValidationResult.isValid()
returning false
.
Default implementation of ValidationResult.isValid()
is safe for null
values.
Be cautious about returning null
if not using the default implementation for ValidationResult.isValid()
.
getErrors
in interface ValidationResult
ValidationResult.isValid()
,
ValidationError
@Deprecated public ServiceException throwIfInvalid(String msg) throws ServiceException
throwIfNotSuccessful(String)
ValidationResult
ServiceException
and throws it.
Checks for both: ValidationResult.isValid()
and ValidationResult.isAuthorized()
.
Issues:
This method is deprecated since 5.10, please use ValidationResult.throwIfNotSuccessful(String)
throwIfInvalid
in interface ValidationResult
ServiceException
ValidationResult.throwIfNotSuccessful(String)
@Deprecated public void throwIfNotValid(String msg) throws ServiceException
throwIfNotSuccessful(String)
ValidationResult
ServiceException
and throws it.
Checks for both: ValidationResult.isValid()
and ValidationResult.isAuthorized()
.
Issues:
This method is deprecated since 5.10, please use ValidationResult.throwIfNotSuccessful(String)
throwIfNotValid
in interface ValidationResult
ServiceException
ValidationResult.throwIfNotSuccessful(String)
@Deprecated public ServiceException throwIfInvalid() throws ServiceException
throwIfNotSuccessful()
ValidationResult
First validation error will be used as message string
This method is deprecated since 5.10, please use ValidationResult.throwIfNotSuccessful()
throwIfInvalid
in interface ValidationResult
ServiceException
ValidationResult.throwIfNotSuccessful()
public void throwIfNotSuccessful(String msg) throws ServiceException
ValidationResult
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 ValidationResult.isNotSuccessful()
.
throwIfNotSuccessful
in interface ValidationResult
ServiceException
ValidationResult.isNotSuccessful()
,
ValidationResult.convertToServiceException(String)
public void throwIfNotSuccessful() throws ServiceException
ValidationResult
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 ValidationResult.isNotSuccessful()
.
throwIfNotSuccessful
in interface ValidationResult
ServiceException
ValidationResult.isNotSuccessful()
,
ValidationResult.convertToServiceException(String)
,
ValidationResult.getErrors()
,
ValidationError
public ServiceException convertToServiceException(@Nullable String errorMsg)
ValidationResult
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 ValidationResult.throwIfNotSuccessful()
and ValidationResult.throwIfNotSuccessful(String)
convertToServiceException
in interface ValidationResult
errorMsg
- message to put in the Exception returnedServiceException
subclass.ValidationResult.throwIfNotSuccessful()
,
ValidationResult.throwIfNotSuccessful(String)
public static SimpleMergeValidationResult.Builder builder(ValidationResult result)
Copyright © 2003–2021 Atlassian. All rights reserved.