@PublicApi public interface

ErrorCollection

com.atlassian.jira.util.ErrorCollection
Known Indirect Subclasses

@PublicApi

This interface is designed for plugins to consume (call its methods).

Clients of @PublicApi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicApi as per each product's API policy as long as the client does not implement/extend @PublicApi interfaces or classes (refer to each product's API policy for the exact guarantee---usually binary compatibility is guaranteed at least across minor versions).

Note: since @PublicApi interfaces and classes are not designed to be implemented or extended by clients, we may perform certain types of binary-incompatible changes to these classes and interfaces, but these will not affect well-behaved clients that do not extend/implement these types (in general, only classes and interfaces annotated with @PublicSpi are safe to extend/implement).

Class Overview

A very simple interface to collect errors. This is typically used during form validation for collecting field validation errors (use addError(String, String)), and general errors (addErrorMessage(String)) that aren't field-specific (eg. permission problems).

Summary

Nested Classes
enum ErrorCollection.Reason  
Public Methods
void addError(String field, String message)
Add a field-specific error message.
void addError(String field, String message, ErrorCollection.Reason reason)
Add a field-specific error message.
void addErrorCollection(ErrorCollection errors)
Populate this ErrorCollection with general and field-specific errors.
void addErrorMessage(String message, ErrorCollection.Reason reason)
Add error message relating to system state (not field-specific), and a reason.
void addErrorMessage(String message)
Add error message relating to system state (not field-specific).
void addErrorMessages(Collection<String> errorMessages)
Append new error messages to those already collected.
void addErrors(Map<StringString> errors)
Append new field-specific errors to those already collected.
void addReason(ErrorCollection.Reason reason)
Add a reason why the function has not been performed.
void addReasons(Set<ErrorCollection.Reason> reasons)
Add reasons why the function has not been performed.
Collection<String> getErrorMessages()
Get all non field-specific error messages.
Map<StringString> getErrors()
Get all field-specific errors.
Collection<String> getFlushedErrorMessages()
Get error messages, then get rid of them.
Set<ErrorCollection.Reason> getReasons()
A set of well known reasons why the function has not been performed.
boolean hasAnyErrors()
Whether any errors (of any type - field-specific or otherwise) have been collected.
void setErrorMessages(Collection<String> errorMessages)
Populate this ErrorCollection with a new set of messages (existing errors are lost).
void setReasons(Set<ErrorCollection.Reason> reasons)
Set reasons why the function has not been performed.

Public Methods

public void addError (String field, String message)

Add a field-specific error message.

Parameters
field Field name, eg. "assignee"
message Error message.

public void addError (String field, String message, ErrorCollection.Reason reason)

Add a field-specific error message.

Parameters
field Field name, eg. "assignee"
message Error message.
reason Reason for the error.

public void addErrorCollection (ErrorCollection errors)

Populate this ErrorCollection with general and field-specific errors.

Parameters
errors ErrorCollection whose errors/messages we obtain.

public void addErrorMessage (String message, ErrorCollection.Reason reason)

Add error message relating to system state (not field-specific), and a reason.

Parameters
message Error message.
reason Reason for the error.

public void addErrorMessage (String message)

Add error message relating to system state (not field-specific).

Parameters
message Error message.

public void addErrorMessages (Collection<String> errorMessages)

Append new error messages to those already collected.

Parameters
errorMessages Collection of error strings.

public void addErrors (Map<StringString> errors)

Append new field-specific errors to those already collected.

Parameters
errors of String: String pairs, eg. {"assignee": "Assignee is required"}

public void addReason (ErrorCollection.Reason reason)

Add a reason why the function has not been performed. The reasons may be used by callers of services to set return codes etc. for example in REST services.

Parameters
reason a well known reasons why the function has not been performed.

public void addReasons (Set<ErrorCollection.Reason> reasons)

Add reasons why the function has not been performed. The reasons may be used by callers of services to set return codes etc. for example in REST services.

Parameters
reasons a set of well known reasons why the function has not been performed.

public Collection<String> getErrorMessages ()

Get all non field-specific error messages.

Returns
  • Collection of error Strings.

public Map<StringString> getErrors ()

Get all field-specific errors.

Returns
  • Map of String: String pairs, eg. {"assignee": "Assignee is required"}

public Collection<String> getFlushedErrorMessages ()

Get error messages, then get rid of them.

Returns
  • The (now cleared) error messages.

public Set<ErrorCollection.Reason> getReasons ()

A set of well known reasons why the function has not been performed. The reasons may be used by callers of services to set return codes etc. for example in REST services.

Returns
  • a set of well known reasons why the function has not been performed.

public boolean hasAnyErrors ()

Whether any errors (of any type - field-specific or otherwise) have been collected.

Returns
  • true if any errors (of any type - field-specific or otherwise) have been collected.

public void setErrorMessages (Collection<String> errorMessages)

Populate this ErrorCollection with a new set of messages (existing errors are lost).

Parameters
errorMessages List of error message Strings.

public void setReasons (Set<ErrorCollection.Reason> reasons)

Set reasons why the function has not been performed. The reasons may be used by callers of services to set return codes etc. for example in REST services.

Parameters
reasons a set of well known reasons why the function has not been performed.