Class ServiceErrorCollector

java.lang.Object
com.atlassian.greenhopper.service.util.ServiceErrorCollector

public class ServiceErrorCollector extends Object
This class can be used when multiple validation errors can be returned simultaneously. Errors resulting from invoking the collect and collectOrGet methods are aggregated, and can be checked using the validate method.
  • Constructor Details

    • ServiceErrorCollector

      public ServiceErrorCollector()
  • Method Details

    • collect

      public void collect(ServiceResult result)
      Checks the given ServiceOutcome, and if it is invalid, adds the errors it contains to this error collector.
    • collectOrGet

      public <T> T collectOrGet(ServiceOutcome<T> result)
      Checks the given ServiceOutcome. If it is valid, the value that it holds is returned. If it is invalid, the errors added to this error collector and null is returned.
    • collectOrGet

      public <T> T collectOrGet(com.atlassian.jira.bc.ServiceOutcome<T> result)
      Checks the given ServiceOutcome. If it is valid, the value that it holds is returned. If it is invalid, the errors added to this error collector and null is returned.
    • validate

      public void validate() throws ServiceOutcomeException
      Checks if this ErrorCollection contains any errors, and if so, an ServiceOutcomeException is thrown. The exception thrown contains all the errors that are held by this error collector.
      Throws:
      ServiceOutcomeException
    • isLastResultValid

      public Optional<Boolean> isLastResultValid()
      Returns a value indicating if the last invocation of collect or collectOrGet was invoked on a ServiceOutcome that was valid. Empty Optional is returned only if there was no previous invocation of collect or collectOrGet.