com.atlassian.jira.issue.fields.CustomField
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

Custom Field interface.

Typically one obtains a CustomField using CustomFieldManager, eg. getCustomFieldObjectByName(String)

To create or update an instance of a CustomField for an issue use createValue(com.atlassian.jira.issue.Issue, Object) or updateValue(com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem, com.atlassian.jira.issue.Issue, com.atlassian.jira.issue.ModifiedValue, com.atlassian.jira.issue.util.IssueChangeHolder).

Summary

Constants
String ENTITY_CF_TYPE_KEY
String ENTITY_CUSTOM_FIELD_SEARCHER
String ENTITY_DESCRIPTION
String ENTITY_ID
String ENTITY_ISSUETYPE
String ENTITY_NAME
String ENTITY_PROJECT
String ENTITY_TABLE_NAME
[Expand]
Inherited Constants
From interface com.atlassian.jira.issue.fields.NavigableField
From interface com.atlassian.jira.issue.fields.OrderableField
Public Methods
int compare(Issue issue1, Issue issue2)
This method compares the values of this custom field in two given issues.
List<IssueType> getAssociatedIssueTypeObjects()
Returns a list of issue types associated with this custom field.
List<IssueType> getAssociatedIssueTypes()
Returns a list of issue types associated with this custom field.
List<Project> getAssociatedProjectObjects()
Returns a list of projects associated with this custom field.
ClauseNames getClauseNames()
Return the JQL clause names that this custom field should be recognized by.
List<FieldConfigScheme> getConfigurationSchemes()
Returns a list of configuration schemes.
CustomFieldSearcher getCustomFieldSearcher()
Retrieves the CustomFieldSearcher for this custom field.
CustomFieldType getCustomFieldType()
Looks up the CustomFieldType.
CustomFieldParams getCustomFieldValues(Map customFieldValuesHolder)
Get the custom field string values that are relevant to this particular custom field
String getDescription()
Returns the 1i8n'ed description of this custom field.
@Nonnull RenderableProperty getDescriptionProperty()
Returns a RenderableProperty for rendering this custom field's description.
String getFieldName()
Returns the title of this custom field.
@Deprecated GenericValue getGenericValue()
This method is deprecated. Use getName(), getDescription(), etc. Since v3.0.
Long getIdAsLong()
Returns ID of this custom field.
Options getOptions(String key, FieldConfig config, JiraContextNode contextNode)
Returns options for this custom field if it is of MultipleCustomFieldType type.
Options getOptions(String key, JiraContextNode jiraContextNode)
Returns options for this custom field if it is of MultipleCustomFieldType type.
PropertySet getPropertySet()
FieldConfig getRelevantConfig(IssueContext issueContext)
Returns the relevant field config of this custom field for the give issue context
FieldConfig getRelevantConfig(Issue issue)
Returns a relevant FieldConfig for the given issue.
FieldConfig getReleventConfig(SearchContext searchContext)
The FieldConfig that is relevent to all issue contexts in the search context Checks that all configs within search context are the same - i.e.
String getUntranslatedDescription()
Returns the description of this custom field by reading ENTITY_DESCRIPTION of the underlying generic value.
@Nonnull RenderableProperty getUntranslatedDescriptionProperty()
Returns a RenderableProperty for rendering this custom field's untranslated description, for admin.
String getUntranslatedName()
Returns the name of this custom field by reading ENTITY_NAME of the underlying generic value.
Object getValue(Issue issue)
Retrieves and returns the Object representing the this CustomField value for the given issue.
boolean isAllIssueTypes()
Returns true if it applies for all issue types, false otherwise.
boolean isAllProjects()
Checks whether this custom field applies for all projects.
boolean isEditable()
Returns true if this custom field can be edited, false otherwise.
boolean isEnabled()
Returns true if all configuration schemes returned by getConfigurationSchemes() are enabled.
boolean isGlobal()
Returns true if this custom field applies for all projects and all issue types.
boolean isInScope(SearchContext searchContext)
Determines whether this custom field is in scope.
boolean isInScope(Project project, List<String> issueTypeIds)
Determines if this custom field is within the scope of the given project, and list of Issue Types.
boolean isInScope(long projectId, String issueTypeId)
Determines if this custom field is within the scope of the given project, and Issue Type.
boolean isInScopeForSearch(Project project, List<String> issueTypeIds)
Determines if this custom field is within the scope of the given project, and list of Issue Types.
boolean isRelevantForIssueContext(IssueContext issueContext)
Returns true if the custom field has a config for the Project and Issue Type of the given IssueContext.
@Deprecated Set<Long> remove()
This method is deprecated. Use removeCustomField(CustomField) instead. Since v7.0.
void validateFromActionParams(Map actionParameters, ErrorCollection errorCollection, FieldConfig config)
Validates relevant parameters on custom field type of this custom field.
[Expand]
Inherited Methods
From interface com.atlassian.jira.issue.fields.ConfigurableField
From interface com.atlassian.jira.issue.fields.Field
From interface com.atlassian.jira.issue.fields.NavigableField
From interface com.atlassian.jira.issue.fields.OrderableField
From interface com.atlassian.jira.issue.fields.SearchableField
From interface com.atlassian.jira.issue.fields.renderer.RenderableField
From interface com.atlassian.jira.issue.fields.rest.RestAwareField
From interface com.atlassian.jira.issue.fields.rest.RestFieldOperations
From interface java.lang.Comparable

Constants

public static final String ENTITY_CF_TYPE_KEY

Constant Value: "customfieldtypekey"

public static final String ENTITY_CUSTOM_FIELD_SEARCHER

Constant Value: "customfieldsearcherkey"

public static final String ENTITY_DESCRIPTION

Constant Value: "description"

public static final String ENTITY_ID

Constant Value: "id"

public static final String ENTITY_ISSUETYPE

Constant Value: "issuetype"

public static final String ENTITY_NAME

Constant Value: "name"

public static final String ENTITY_PROJECT

Constant Value: "project"

public static final String ENTITY_TABLE_NAME

Constant Value: "CustomField"

Public Methods

public int compare (Issue issue1, Issue issue2)

This method compares the values of this custom field in two given issues.

Returns a negative integer, zero, or a positive integer as the value of first issue is less than, equal to, or greater than the value of the second issue.

If either of given issues is null a IllegalArgumentException is thrown.

Parameters
issue1 issue to compare
issue2 issue to compare
Returns
  • a negative integer, zero, or a positive integer as the value of first issue is less than, equal to, or greater than the value of the second issue
Throws
IllegalArgumentException if any of given issues is null

public List<IssueType> getAssociatedIssueTypeObjects ()

Returns a list of issue types associated with this custom field. Will be null if the field is global

Returns
  • List of issue type generic values

public List<IssueType> getAssociatedIssueTypes ()

Returns a list of issue types associated with this custom field. Will be null if the field is global

Returns
  • List of issue type generic values

public List<Project> getAssociatedProjectObjects ()

Returns a list of projects associated with this custom field. Will be null if the field is global

Returns
  • a list of projects associated with this custom field.

public ClauseNames getClauseNames ()

Return the JQL clause names that this custom field should be recognized by.

Returns
  • the clause names this custom field should be recognized by.

public List<FieldConfigScheme> getConfigurationSchemes ()

Returns a list of configuration schemes.

Returns

public CustomFieldSearcher getCustomFieldSearcher ()

Retrieves the CustomFieldSearcher for this custom field. The searcher, if found is initialized with this custom field before it is returned.

Returns
  • found custom field searcher or null, if none found

public CustomFieldType getCustomFieldType ()

Looks up the CustomFieldType. It can return null if the custom field type cannot be found in the CustomFieldManager.

Returns
  • custom field type

public CustomFieldParams getCustomFieldValues (Map customFieldValuesHolder)

Get the custom field string values that are relevant to this particular custom field

Parameters
customFieldValuesHolder containing all params
Returns

public String getDescription ()

Returns the 1i8n'ed description of this custom field. To render views for the custom field description, prefer getDescriptionProperty().

Returns
  • the description of this custom field

@Nonnull public RenderableProperty getDescriptionProperty ()

Returns a RenderableProperty for rendering this custom field's description.

Returns
  • a read-only RenderableProperty

public String getFieldName ()

Returns the title of this custom field.

Returns
  • the title of this custom field

@Deprecated public GenericValue getGenericValue ()

This method is deprecated.
Use getName(), getDescription(), etc. Since v3.0.

Returns a generic value that represents this custom field

Returns
  • generic value of this custom field

public Long getIdAsLong ()

Returns ID of this custom field.

Returns
  • ID of this custom field

public Options getOptions (String key, FieldConfig config, JiraContextNode contextNode)

Returns options for this custom field if it is of MultipleCustomFieldType type. Otherwise returns null.

As this is just used by the view layer, it can be a list of objects

Parameters
key not used
config relevant field config
contextNode JIRA context node
Returns

public Options getOptions (String key, JiraContextNode jiraContextNode)

Returns options for this custom field if it is of MultipleCustomFieldType type. Otherwise returns null.

As this is just used by the view layer, it can be a list of objects

Parameters
key not used
jiraContextNode JIRA context node
Returns

public PropertySet getPropertySet ()

public FieldConfig getRelevantConfig (IssueContext issueContext)

Returns the relevant field config of this custom field for the give issue context

Parameters
issueContext issue context to find the relevant field config for
Returns
  • the relevant field config of this custom field for the give issue context

public FieldConfig getRelevantConfig (Issue issue)

Returns a relevant FieldConfig for the given issue. If the field has a config for the issue then one will be returned, otherwise null is returned.

For example, if we have 2 projects: project A and project B, and a custom field is configured to be only applicable to project A, calling getRelevantConfig with an issue from project A should return the config (i.e. not null). Calling this method with an issue from project B should return null.

Parameters
issue issue whose project and issue type will be used to check if the field has a config
Returns
  • an instance of FieldConfig representing the configuration of the field for issue's project/issue type. If the field does not have a config for issue's project/issue type, null is returned.

public FieldConfig getReleventConfig (SearchContext searchContext)

The FieldConfig that is relevent to all issue contexts in the search context Checks that all configs within search context are the same - i.e. all null or all the same config.

Returns null if any two configs are different.

Note: null config is not equal to non-null config. Previously, a non-null config was returned even if the first config(s) was null.

Parameters
searchContext search context
Returns
  • null if any two configs are different

public String getUntranslatedDescription ()

Returns the description of this custom field by reading ENTITY_DESCRIPTION of the underlying generic value.

Returns
  • the description of this custom field

@Nonnull public RenderableProperty getUntranslatedDescriptionProperty ()

Returns a RenderableProperty for rendering this custom field's untranslated description, for admin.

Returns
  • a read-only RenderableProperty

public String getUntranslatedName ()

Returns the name of this custom field by reading ENTITY_NAME of the underlying generic value.

Returns
  • the name of this custom field

public Object getValue (Issue issue)

Retrieves and returns the Object representing the this CustomField value for the given issue. See getValueFromIssue(CustomField, Issue). This is only used to communicate with the 'view' JSP. Multiselects will return a list, dates a date, etc.

Parameters
issue issue to retrieve the value from
Returns
  • Object representing the this CustomField value for the given issue

public boolean isAllIssueTypes ()

Returns true if it applies for all issue types, false otherwise.

Returns
  • true if it applies for all issue types, false otherwise.

public boolean isAllProjects ()

Checks whether this custom field applies for all projects. It returns true if it applies for all projects for any field configuration scheme, false otherwise.

Returns
  • true if it applies for all projects for any field configuration scheme, false otherwise.

public boolean isEditable ()

Returns true if this custom field can be edited, false otherwise.

Returns
  • true if this custom field can be edited, false otherwise

public boolean isEnabled ()

Returns true if all configuration schemes returned by getConfigurationSchemes() are enabled.

Returns
  • true if all configuration schemes are enabled, false otherwise

public boolean isGlobal ()

Returns true if this custom field applies for all projects and all issue types.

Returns
  • true if it is in all projects and all issue types, false otherwise.

public boolean isInScope (SearchContext searchContext)

Determines whether this custom field is in scope.

Parameters
searchContext search context
Returns
  • true if this field is in scope

public boolean isInScope (Project project, List<String> issueTypeIds)

Determines if this custom field is within the scope of the given project, and list of Issue Types.

Parameters
project The project.
issueTypeIds A list of IssueType ids.
Returns
  • true if this custom field is within the given scope.

public boolean isInScope (long projectId, String issueTypeId)

Determines if this custom field is within the scope of the given project, and Issue Type.

Parameters
projectId The project.
issueTypeId The issueTypeId
Returns
  • true if this custom field is within the given scope.

public boolean isInScopeForSearch (Project project, List<String> issueTypeIds)

Determines if this custom field is within the scope of the given project, and list of Issue Types.

If the project is null, then it is treated as any project. If the issueTypeIds list is null or an empty list, then it is treated as any issue type.

If the passed project is any project, this method will search in all the FieldConfigScheme of this custom field, ignoring the projects that they apply to (since the given project is any) and looking for at least one of them that applies to at least one of the given issue type ids.

If the passed list of issue types is any issue type, this method will search for at least one FieldConfigScheme that applies to the given project, ignoring the issue types that it applies to (since the given issue type ids are any).

If both the project and issue types are any, the question being asked is "is this custom field in the scope of any project and any issue type?", which will always be true.

public boolean isRelevantForIssueContext (IssueContext issueContext)

Returns true if the custom field has a config for the Project and Issue Type of the given IssueContext.

This is equivalent to calling

  getRelevantConfig(issueContext) != null
but in general can run faster because it does not have to resolve the actual FieldConfig.

Parameters
issueContext IssueContext whose project and issue type will be used to check if the field has a config
Returns
  • an instance of FieldConfig representing the configuration of the field for issue's project/issue type. If the field does not have a config for issue's project/issue type, null is returned.

@Deprecated public Set<Long> remove ()

This method is deprecated.
Use removeCustomField(CustomField) instead. Since v7.0.

Removes this custom field and returns a set of issue IDs of all issues that are affected by removal of this custom field.

Returns
  • a set of issue IDs of affected issues
Throws
DataAccessException if removal of generic value fails

public void validateFromActionParams (Map actionParameters, ErrorCollection errorCollection, FieldConfig config)

Validates relevant parameters on custom field type of this custom field. Any errors found are added to the given errorCollection. See validateFromParams(CustomFieldParams, ErrorCollection, FieldConfig)

Parameters
actionParameters action parameters
errorCollection error collection to add errors to
config field config