public class

MockCustomFieldType

extends Object
implements CustomFieldType<T, S>
java.lang.Object
   ↳ com.atlassian.jira.action.issue.customfields.MockCustomFieldType

Class Overview

Mocks a CustomFieldType

Summary

[Expand]
Inherited Constants
From interface com.atlassian.jira.issue.customfields.CustomFieldType
Public Constructors
MockCustomFieldType()
MockCustomFieldType(String key, String name)
MockCustomFieldType(String key, String name, String description)
Public Methods
String availableForBulkEdit(BulkEditBean bulkEditBean)
Allow the custom field type perform a specific check as to its availability for bulk editing.
void createValue(CustomField field, Issue issue, Object value)
String getChangelogString(CustomField field, Object value)
String getChangelogValue(CustomField field, Object value)
@Nonnull List<FieldConfigItemType> getConfigurationItemTypes()
Returns a List of FieldConfigItemType objects.
Object getDefaultValue(FieldConfig fieldConfig)
Retrieves the Object representing the default CustomField value for the Custom Field.
String getDescription()
CustomFieldTypeModuleDescriptor getDescriptor()
String getKey()
Returns the full key of the CustomFieldType.
String getName()
List<FieldIndexer> getRelatedIndexers(CustomField customField)
Returns a list of indexers that will be used for the field.
Object getSingularObjectFromString(String string)
Returns a Singular Object, given the string value as passed by the presentation tier.
String getStringFromSingularObject(Object singularObject)
Object getStringValueFromCustomFieldParams(CustomFieldParams parameters)
Return the String value object from the CustomFieldParams.
Object getValueFromCustomFieldParams(CustomFieldParams parameters)
Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.
Object getValueFromIssue(CustomField field, Issue issue)
Retrieves the Transport Object representing the current CustomField value for the given issue.
@Nonnull Map<StringObject> getVelocityParameters(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem)
The custom field may wish to pass parameters to the velocity context beyond the getValueFromIssue methods (eg managers).
void init(CustomFieldTypeModuleDescriptor customFieldTypeModuleDescriptor)
Initialises the CustomFieldType with the given descriptor.
boolean isRenderable()
This is a mirror of the method from the RenderableField interface and is needed to bridge the gap between CustomFields and CustomFieldTypes.
Set<Long> remove(CustomField field)
Performs additional tasks when an entire CustomField of this type is being removed remove().
MockCustomFieldType setConfigurationItemTypes(List<FieldConfigItemType> itemTypes)
void setDefaultValue(FieldConfig fieldConfig, Object value)
void setKey(String key)
void setName(String name)
String toString()
void updateValue(CustomField field, Issue issue, Object value)
void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)
Ensures that the CustomFieldParams of Strings is a valid representation of the Custom Field values.
boolean valuesEqual(Object v1, Object v2)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.issue.customfields.CustomFieldType

Public Constructors

public MockCustomFieldType ()

public MockCustomFieldType (String key, String name)

public MockCustomFieldType (String key, String name, String description)

Public Methods

public String availableForBulkEdit (BulkEditBean bulkEditBean)

Allow the custom field type perform a specific check as to its availability for bulk editing.

Parameters
bulkEditBean BulkEditBean
Returns
  • null if available for bulk edit or appropriate unavailable message

public void createValue (CustomField field, Issue issue, Object value)

public String getChangelogString (CustomField field, Object value)

public String getChangelogValue (CustomField field, Object value)

@Nonnull public List<FieldConfigItemType> getConfigurationItemTypes ()

Returns a List of FieldConfigItemType objects. Can not be immutable. This opens up possibilities for configurable custom fields.

Returns

public Object getDefaultValue (FieldConfig fieldConfig)

Retrieves the Object representing the default CustomField value for the Custom Field.

Parameters
fieldConfig CustomField for default value
Returns
  • Transport Object of the Default Value

public String getDescription ()

public CustomFieldTypeModuleDescriptor getDescriptor ()

public String getKey ()

Returns the full key of the CustomFieldType. Typically, this will be prefixed with "com.atlassian.jira.plugin.system.customfieldtypes:"

Returns
  • CustomFieldType Key prefixed with the Package

public String getName ()

public List<FieldIndexer> getRelatedIndexers (CustomField customField)

Returns a list of indexers that will be used for the field.

Parameters
customField the custom field to get the related indexers of.
Returns
  • List of instantiated and initialised FieldIndexer objects. Null if no related indexers.

public Object getSingularObjectFromString (String string)

Returns a Singular Object, given the string value as passed by the presentation tier. Throws FieldValidationException if the string is an invalid representation of the Object.

Parameters
string the String
Returns
  • singularObject instance

public String getStringFromSingularObject (Object singularObject)

public Object getStringValueFromCustomFieldParams (CustomFieldParams parameters)

Return the String value object from the CustomFieldParams. The object may be a single String (e.g. TextCFType, List of Strings (e.g. MultiSelectCFType) or CustomFieldParams of Strings (e.g. CascadingSelectCFType). Among other things these values are passed to Velocity for rendering edit screens.

Parameters
parameters - CustomFieldParams containing String values
Returns
  • String value object from the CustomFieldParams

public Object getValueFromCustomFieldParams (CustomFieldParams parameters)

Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.

Parameters
parameters CustomFieldParams of String objects. Will contain one value for Singular field types.
Returns

public Object getValueFromIssue (CustomField field, Issue issue)

Retrieves the Transport Object representing the current CustomField value for the given issue.

Parameters
field Custom field for which to retrieve the value
issue Issue from which to retrieve the value
Returns

@Nonnull public Map<StringObject> getVelocityParameters (Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem)

The custom field may wish to pass parameters to the velocity context beyond the getValueFromIssue methods (eg managers).

The values are added to the context for all velocity views (edit, search, view, xml)

Parameters
issue The issue currently in context (Note: this will be null in cases like 'default value')
field CustomField
fieldLayoutItem FieldLayoutItem
Returns
  • A Map of parameters to add to the velocity context, or an empty Map otherwise (never null)

public void init (CustomFieldTypeModuleDescriptor customFieldTypeModuleDescriptor)

Initialises the CustomFieldType with the given descriptor.

Parameters
customFieldTypeModuleDescriptor CustomFieldTypeModuleDescriptor

public boolean isRenderable ()

This is a mirror of the method from the RenderableField interface and is needed to bridge the gap between CustomFields and CustomFieldTypes.

Returns
  • true if the field is configurable for use with the renderers, a text based field, false otherwise.

public Set<Long> remove (CustomField field)

Performs additional tasks when an entire CustomField of this type is being removed remove(). This includes removal of values & options.

Parameters
field The custom field that is being removed, so any data stored for any issues for that field can be deleted.
Returns
  • Set of issue ids that has been affected

public MockCustomFieldType setConfigurationItemTypes (List<FieldConfigItemType> itemTypes)

public void setDefaultValue (FieldConfig fieldConfig, Object value)

public void setKey (String key)

public void setName (String name)

public String toString ()

public void updateValue (CustomField field, Issue issue, Object value)

public void validateFromParams (CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)

Ensures that the CustomFieldParams of Strings is a valid representation of the Custom Field values. Any errors should be added to the ErrorCollection under the appropriate key as required.

Parameters
relevantParams parameter object of Strings
errorCollectionToAddTo errorCollection to which any errors should be added (never null)
config FieldConfig

public boolean valuesEqual (Object v1, Object v2)