com.atlassian.jira.issue.customfields.impl
Class CalculatedCFType<T,S>

java.lang.Object
  extended by com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType<T,S>
      extended by com.atlassian.jira.issue.customfields.impl.CalculatedCFType<T,S>
Type Parameters:
T - Transport Object as defined in CustomFieldType
S - Single Object contained within the Transport Object as defined in CustomFieldType
All Implemented Interfaces:
CustomFieldType<T,S>, SortableCustomField<T>

@PublicSpi
public abstract class CalculatedCFType<T,S>
extends AbstractCustomFieldType<T,S>
implements SortableCustomField<T>

A CustomFieldType which is calculated rather than set. Transport Object is defined by subclass


Nested Class Summary
static interface CalculatedCFType.Visitor<X>
           
 
Nested classes/interfaces inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
AbstractCustomFieldType.VisitorBase<X>
 
Field Summary
 
Fields inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
DEFAULT_VALUE_TYPE
 
Constructor Summary
CalculatedCFType()
           
 
Method Summary
 Object accept(AbstractCustomFieldType.VisitorBase visitor)
           
 int compare(T o1, T o2, FieldConfig fieldConfig)
          Compares the two custom field objects.
 void createValue(CustomField field, Issue issue, T value)
          Save the value for this Custom Field in a particular issue to the database.
 String getChangelogValue(CustomField field, T value)
          Returns a values to be stored in the change log, example is the id of the changed item.
 List<FieldConfigItemType> getConfigurationItemTypes()
          Returns a List of FieldConfigItemType objects.
 T getDefaultValue(FieldConfig fieldConfig)
          Retrieves the Object representing the default CustomField value for the Custom Field.
 Object getStringValueFromCustomFieldParams(CustomFieldParams parameters)
          Return the String value object from the CustomFieldParams.
 T getValueFromCustomFieldParams(CustomFieldParams parameters)
          Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.
 Set<Long> remove(CustomField field)
          Performs additional tasks when an entire CustomField of this type is being removed CustomField.remove().
 void setDefaultValue(FieldConfig fieldConfig, T value)
          Sets the default value for a Custom Field
 void updateValue(CustomField field, Issue issue, T value)
          Upadte the value for this Custom Field in a particular issue currently stored in the database.
 void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)
          Ensures that the CustomFieldParams of Strings is a valid representation of the Custom Field values.
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
assertObjectImplementsType, availableForBulkEdit, getChangelogString, 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
getSingularObjectFromString, getStringFromSingularObject, getValueFromIssue
 

Constructor Detail

CalculatedCFType

public CalculatedCFType()
Method Detail

remove

public Set<Long> remove(CustomField field)
Description copied from interface: CustomFieldType
Performs additional tasks when an entire CustomField of this type is being removed CustomField.remove(). This includes removal of values & options.

Specified by:
remove in interface CustomFieldType<T,S>
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

validateFromParams

public void validateFromParams(CustomFieldParams relevantParams,
                               ErrorCollection errorCollectionToAddTo,
                               FieldConfig config)
Description copied from interface: CustomFieldType
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.

Specified by:
validateFromParams in interface CustomFieldType<T,S>
Parameters:
relevantParams - parameter object of Strings
errorCollectionToAddTo - errorCollection to which any erros should be added (never null)
config - FieldConfig

createValue

public void createValue(CustomField field,
                        Issue issue,
                        T value)
Description copied from interface: CustomFieldType
Save the value for this Custom Field in a particular issue to the database.

Specified by:
createValue in interface CustomFieldType<T,S>
Parameters:
field - CustomField for which the value is being stored
issue - The Issue to be stored against.
value - Transport Object representing the value instance of the CustomField.

updateValue

public void updateValue(CustomField field,
                        Issue issue,
                        T value)
Description copied from interface: CustomFieldType
Upadte the value for this Custom Field in a particular issue currently stored in the database.

Specified by:
updateValue in interface CustomFieldType<T,S>
Parameters:
field - CustomField for which the value is being stored
issue - The Issue to be stored against.
value - Transport Object representing the value instance of the CustomField.

getDefaultValue

public T getDefaultValue(FieldConfig fieldConfig)
Description copied from interface: CustomFieldType
Retrieves the Object representing the default CustomField value for the Custom Field.

Specified by:
getDefaultValue in interface CustomFieldType<T,S>
Parameters:
fieldConfig - CustomField for default value
Returns:
Transport Object of the Default Value

setDefaultValue

public void setDefaultValue(FieldConfig fieldConfig,
                            T value)
Description copied from interface: CustomFieldType
Sets the default value for a Custom Field

Specified by:
setDefaultValue in interface CustomFieldType<T,S>
Parameters:
fieldConfig - CustomField for which the default is being stored
value - Transport Object representing the value instance of the CustomField

getChangelogValue

public String getChangelogValue(CustomField field,
                                T value)
Description copied from interface: CustomFieldType
Returns a values to be stored in the change log, example is the id of the changed item.

Specified by:
getChangelogValue in interface CustomFieldType<T,S>
Parameters:
field - CustomField that the value belongs to
value - Transport Object representing the value instance of the CustomField
Returns:
Change log value.

getValueFromCustomFieldParams

public T getValueFromCustomFieldParams(CustomFieldParams parameters)
                                throws FieldValidationException
Description copied from interface: CustomFieldType
Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.

Specified by:
getValueFromCustomFieldParams in interface CustomFieldType<T,S>
Parameters:
parameters - CustomFieldParams of String objects. Will contain one value for Singular field types.
Returns:
Transport Object matching the Object parameter of CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, T), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, T)
Throws:
FieldValidationException - if the String value fails to convert into Objects
See Also:
CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, Object), CustomFieldType.getValueFromIssue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue)

getStringValueFromCustomFieldParams

public Object getStringValueFromCustomFieldParams(CustomFieldParams parameters)
Description copied from interface: CustomFieldType
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.

Specified by:
getStringValueFromCustomFieldParams in interface CustomFieldType<T,S>
Parameters:
parameters - - CustomFieldParams containing String values
Returns:
String value object from the CustomFieldParams

compare

public int compare(@NotNull
                   T o1,
                   @NotNull
                   T o2,
                   FieldConfig fieldConfig)
Description copied from interface: SortableCustomField
Compares the two custom field objects.

Specified by:
compare in interface SortableCustomField<T>
Parameters:
o1 - Never null
o2 - Never null
Returns:
0, 1 or -1

getConfigurationItemTypes

@NotNull
public List<FieldConfigItemType> getConfigurationItemTypes()
Description copied from interface: CustomFieldType
Returns a List of FieldConfigItemType objects. Can not be immutable. This opens up possibilties for configurable custom fields.

Specified by:
getConfigurationItemTypes in interface CustomFieldType<T,S>
Overrides:
getConfigurationItemTypes in class AbstractCustomFieldType<T,S>
Returns:
List of FieldConfigItemType

accept

public Object accept(AbstractCustomFieldType.VisitorBase visitor)
Overrides:
accept in class AbstractCustomFieldType<T,S>


Copyright © 2002-2012 Atlassian. All Rights Reserved.