@PublicApi public interface

EmailFormatter

com.atlassian.jira.util.EmailFormatter
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

Returned email address appropriately masked/hidden for the current user.

Summary

Public Methods
boolean emailVisible(User currentUser)
Returns whether or not email addresses are visible to this user, as determined by the JIRA_OPTION_EMAIL_VISIBLE setting.
@Nullable String formatEmail(User user, User currentUser)
Formats user's email address for the purpose of displaying it to currentUser, as determined by the JIRA_OPTION_EMAIL_VISIBLE setting.
@Nullable String formatEmail(String email, User currentUser)
Formats an email address for the purpose of displaying it to a user as determined by the JIRA_OPTION_EMAIL_VISIBLE setting.
@Nullable String formatEmail(String email, boolean isCurrentUserLoggedIn)
Formats an email address for the purpose of displaying it to a user as determined by the JIRA_OPTION_EMAIL_VISIBLE setting.
@Nonnull String formatEmailAsLink(String email, User currentUser)
Returns email address as HTML links, if appropriate.

Public Methods

public boolean emailVisible (User currentUser)

Returns whether or not email addresses are visible to this user, as determined by the JIRA_OPTION_EMAIL_VISIBLE setting.

Parameters
currentUser the user to which email addresses will be shown, or null if no user is logged in (browsing anonymously)
Returns
  • true if email addresses should be visible (even if they will be masked); false otherwise

@Nullable public String formatEmail (User user, User currentUser)

Formats user's email address for the purpose of displaying it to currentUser, as determined by the JIRA_OPTION_EMAIL_VISIBLE setting.

This convenience method is exactly equivalent to formatEmail(user.getEmailAddress(), currentUser != null), except that it is null-safe.

Parameters
user owner of the email address to format and display (null is permitted)
currentUser the user to which email addresses will be shown, or null if no user is logged in (browsing anonymously)
Returns
  • the formatted email address; null if either user is null or currentUser is not permitted to see email addresses

@Nullable public String formatEmail (String email, User currentUser)

Formats an email address for the purpose of displaying it to a user as determined by the JIRA_OPTION_EMAIL_VISIBLE setting.

This convenience method is exactly equivalent to formatEmail(email, currentUser != null).

Parameters
email The email address to show/mask/hide.
currentUser The user viewing the email address.
Returns
  • the formatted email address; null if either email is null or the user is not permitted to see email addresses

@Nullable public String formatEmail (String email, boolean isCurrentUserLoggedIn)

Formats an email address for the purpose of displaying it to a user as determined by the JIRA_OPTION_EMAIL_VISIBLE setting.

SettingBehaviour
"show"The email is shown as-is to everyone.
"user"The email is shown as-is to users that are logged in, but not shown to anonymous users.
"mask"The email is shown to all users with the e-mail address slightly obscured, such that "user@example.com" appears as "user at example dot com", instead

Parameters
email The email address to show/mask/hide.
isCurrentUserLoggedIn true if a user is currently logged in; false if the user is browsing anonymously
Returns
  • the formatted email address; null if either email is null or the user is not permitted to see email addresses

@Nonnull public String formatEmailAsLink (String email, User currentUser)

Returns email address as HTML links, if appropriate. If email addresses are masked, then they are returned as HTML-escaped text, but not as links.

Returns
  • <a href="foo@bar.com">foo@bar.com</a> (public), foo at bar.com (masked), or an empty string ("") if either email is null or the user is not permitted to see email addresses