com.atlassian.jira.issue.customfields.impl
Class AbstractMultiCFType

java.lang.Object
  extended by com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
      extended by com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType
          extended by com.atlassian.jira.issue.customfields.impl.StringCFType
              extended by com.atlassian.jira.issue.customfields.impl.TextCFType
                  extended by com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType
All Implemented Interfaces:
ProjectImportableCustomField, CustomFieldType, SortableCustomField
Direct Known Subclasses:
MultiGroupCFType, MultiUserCFType

public abstract class AbstractMultiCFType
extends TextCFType
implements CustomFieldType

Abstract class for Multi-select Custom field types for either Users or Groups. Note that there is also another multi-select Custom Field for arbitrary options - MultiSelectCFType.

The Transport Object for this Custom Field type is a Collection of Users or Collection of Groups; depending on the subclass. Some of these methods will also accept a Collection of String as an input parameter. See the javadoc of updateValue(com.atlassian.jira.issue.fields.CustomField,com.atlassian.jira.issue.Issue,Object), createValue(com.atlassian.jira.issue.fields.CustomField,com.atlassian.jira.issue.Issue,Object), and setDefaultValue(com.atlassian.jira.issue.fields.config.FieldConfig,Object) for instance.

See Also:
CustomFieldType, MultiSelectCFType

Field Summary
 
Fields inherited from class com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType
customFieldValuePersister, FIELD_TYPE_DATE, FIELD_TYPE_NUMBER, FIELD_TYPE_STRING, FIELD_TYPE_TEXT, genericConfigManager, log
 
Fields inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
DEFAULT_VALUE_TYPE
 
Constructor Summary
AbstractMultiCFType(CustomFieldValuePersister customFieldValuePersister, StringConverter stringConverter, GenericConfigManager genericConfigManager)
          Overriden, calls super constructor.
 
Method Summary
protected  Collection convertStringsToTypes(Collection strings)
          Converts a collection of string representations of underlying type to a collection of underlying types.
protected abstract  Object convertStringToType(String string)
          Converts a given String to underlying type
protected  Collection convertTypesToStringsIfRequired(Collection typedList)
          Converts a collection of underlying types to a collection of string representations of underlying type.
protected abstract  String convertTypeToString(Object value)
          Converts a given underlying type to String.
 void createValue(CustomField customField, Issue issue, Object value)
          Create a multi-select value for an issue.
 String getChangelogValue(CustomField field, Object value)
          Returns a string representation of the value if not null.
 Object getDefaultValue(FieldConfig fieldConfig)
          Retrieves the Object representing the default CustomField value for the Custom Field.
protected abstract  Comparator getTypeComparator()
          Returns a comparator for underlying type of this custom field.
 Object getValueFromIssue(CustomField field, Issue issue)
          Retrieves the Object representing the current CustomField value for the given issue.
 void setDefaultValue(FieldConfig fieldConfig, Object value)
          Sets the default value for a Custom Field.
 void updateValue(CustomField customField, Issue issue, Object value)
          Update a multi-select value for an issue.
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.TextCFType
compare, getDatabaseType, getProjectImporter, getSingularObjectFromString, getStringFromSingularObject
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.StringCFType
getDbValueFromObject, getObjectFromDbValue, makeSearchParameter
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType
getStringValueFromCustomFieldParams, getValueFromCustomFieldParams, remove, validateFromParams
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
assertObjectImplementsType, availableForBulkEdit, getChangelogString, getConfigurationItemTypes, getDescription, getDescriptor, getI18nBean, getKey, getName, getRelatedIndexers, getVelocityParameters, getVelocityParameters, init, isRenderable, valuesEqual
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
availableForBulkEdit, getChangelogString, getConfigurationItemTypes, getDescription, getDescriptor, getKey, getName, getRelatedIndexers, getSingularObjectFromString, getStringFromSingularObject, getStringValueFromCustomFieldParams, getValueFromCustomFieldParams, getVelocityParameters, init, isRenderable, remove, validateFromParams, valuesEqual
 

Constructor Detail

AbstractMultiCFType

public AbstractMultiCFType(CustomFieldValuePersister customFieldValuePersister,
                           StringConverter stringConverter,
                           GenericConfigManager genericConfigManager)
Overriden, calls super constructor.

Method Detail

getTypeComparator

protected abstract Comparator getTypeComparator()
Returns a comparator for underlying type of this custom field.

Returns:
a comparator

convertTypeToString

protected abstract String convertTypeToString(Object value)
Converts a given underlying type to String. If the value parameter is already of type String then this String is just returned.

Parameters:
value - underlying type
Returns:
string representation of underlying type

convertStringToType

protected abstract Object convertStringToType(String string)
Converts a given String to underlying type

Parameters:
string - string representation of underlying type
Returns:
underlying type

getDefaultValue

public Object getDefaultValue(FieldConfig fieldConfig)
Description copied from interface: CustomFieldType
Retrieves the Object representing the default CustomField value for the Custom Field. See CustomFieldType.getValueFromCustomFieldParams(com.atlassian.jira.issue.customfields.view.CustomFieldParams) for more detailed notes.

Specified by:
getDefaultValue in interface CustomFieldType
Overrides:
getDefaultValue in class AbstractSingleFieldType
Parameters:
fieldConfig - CustomField for default value
Returns:
Transport Object matching the Object parameter of CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, java.lang.Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, java.lang.Object)
See Also:
CustomFieldType.getDefaultValue(com.atlassian.jira.issue.fields.config.FieldConfig)

setDefaultValue

public void setDefaultValue(FieldConfig fieldConfig,
                            Object value)
Sets the default value for a Custom Field.

The Transport Object for parameter value can be either a Collection of the underlying type (User or Group), or a Collection of String.

Specified by:
setDefaultValue in interface CustomFieldType
Overrides:
setDefaultValue in class AbstractSingleFieldType
Parameters:
fieldConfig - CustomField for which the default is being stored
value - Transport Object representing the value instance of the CustomField.
See Also:
CustomFieldType.setDefaultValue(com.atlassian.jira.issue.fields.config.FieldConfig,Object)

createValue

public void createValue(CustomField customField,
                        Issue issue,
                        Object value)
Create a multi-select value for an issue.

The Transport Object for parameter value can be either a Collection of the underlying type (User or Group), or a Collection of String.

Specified by:
createValue in interface CustomFieldType
Overrides:
createValue in class AbstractSingleFieldType
Parameters:
customField - CustomField for which the value is being stored
issue - The Issue.
value - Transport Object representing the value instance of the CustomField.
See Also:
CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField,com.atlassian.jira.issue.Issue,Object)

updateValue

public void updateValue(CustomField customField,
                        Issue issue,
                        Object value)
Update a multi-select value for an issue.

The Transport Object for parameter value can be either a Collection of the underlying type (User or Group), or a Collection of String.

Specified by:
updateValue in interface CustomFieldType
Overrides:
updateValue in class AbstractSingleFieldType
Parameters:
customField - CustomField for which the value is being stored
issue - The Issue.
value - Transport Object representing the value instance of the CustomField.
See Also:
CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField,com.atlassian.jira.issue.Issue,Object)

getValueFromIssue

public Object getValueFromIssue(CustomField field,
                                Issue issue)
Description copied from interface: CustomFieldType
Retrieves the Object representing the current CustomField value for the given issue. See CustomFieldType.getValueFromCustomFieldParams(com.atlassian.jira.issue.customfields.view.CustomFieldParams) for more detailed notes.

Specified by:
getValueFromIssue in interface CustomFieldType
Overrides:
getValueFromIssue in class AbstractSingleFieldType
Parameters:
field - Custom field for which to retrieve the value
issue - Issue from which to retrieve the value
Returns:
Transport Object matching the Object parameter of CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, java.lang.Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, java.lang.Object)
See Also:
CustomFieldType.getValueFromIssue(com.atlassian.jira.issue.fields.CustomField,com.atlassian.jira.issue.Issue)

getChangelogValue

public String getChangelogValue(CustomField field,
                                Object value)
Returns a string representation of the value if not null.

Specified by:
getChangelogValue in interface CustomFieldType
Overrides:
getChangelogValue in class AbstractSingleFieldType
Parameters:
field - not used
value - value to create a change log for
Returns:
string representaion of value if not null, empty string otherwise

convertTypesToStringsIfRequired

protected final Collection convertTypesToStringsIfRequired(Collection typedList)
Converts a collection of underlying types to a collection of string representations of underlying type. Returns null when typedList is null.

If a Collection of String is passed, then a new Collection is still created, containing the original String values.

Parameters:
typedList - a collection of underlying types
Returns:
a collection of string representations of underlying type

convertStringsToTypes

protected final Collection convertStringsToTypes(Collection strings)
Converts a collection of string representations of underlying type to a collection of underlying types. Returns null when given strings collection is null.

Parameters:
strings - a collection of string representations of underlying type
Returns:
a collection of underlying types


Copyright © 2002-2009 Atlassian. All Rights Reserved.