Making custom fields sortable
We have seen the creation of new custom fields, writing new searchers for them, and so on. Another important feature with the fields, be it custom fields or the standard JIRA fields, is to use them for sorting. But simply writing a new custom field type won't enable sorting on that field.
In this recipe, we will see how to enable sorting on custom fields.
Getting ready
Create the new custom field type that we need to enable searching for.
How to do it...
This is easy to do. There are only two simple steps that you need to do to make sure the custom field is a sortable field:
Implement the
SortableCustomField
interface. A new custom field type will look like the following:public class DemoCFType extends AbstractCustomFieldType implements SortableCustomField
If you are extending an existing custom field type like
TextCFType
, it already implements the interface.Implement the
compare
method. Following is an example:public int compare(Object customFieldObjectValue1, Object...