@PublicSpi public interface

LuceneFieldSorter

com.atlassian.jira.issue.search.LuceneFieldSorter<T>
Known Indirect Subclasses

@PublicSpi

This interface is designed for plugins to implement.

Clients of @PublicSpi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicSpi as per each product's API policy (clients should refer to each product's API policy for the exact guarantee -- usually binary compatibility is guaranteed at least across minor versions).

Note: @PublicSpi interfaces and classes are specifically designed to be implemented/extended by clients. Hence, the guarantee of binary compatibility is different to that of @PublicApi elements (if an element is both @PublicApi and @PublicSpi, both guarantees apply).

Class Overview

Implementations of this interface are used to sort Lucene search results of Issue Documents.

NOTE: instances of this interface are cached by Lucene and are REUSED to sort multiple Lucene search results. The Comparator returned by the getComparator() method could be used by Lucene from multiple threads at once.

Therefore, the implementations of this interface MUST implement the equals(Object) and hashCode() methods correctly to ensure that Lucene can find the implementations of this class in its cache and reuse it, rather than make the cache grow indefinitely. (Unfortunately the Lucene cache is rather primitive at the moment, and is not bound).

Also, ensure that the Comparator returned by the getComparator() method is thread safe.

As instances of this and the Comparator returned by this object are cached and reused by Lucene to sort multiple search results, the best thing to do is to ensure the implementations of this interface and the Comparator that is returned are immutable and that the equals(Object) and hashCode() methods respect the state of the object.

Summary

Public Methods
boolean equals(Object obj)
As this object is used as a key in a cache, this method must be provided and respect all internal state.
Comparator<T> getComparator()
A comparator that can be used to order objects returned by getValueFromLuceneField(String).
String getDocumentConstant()
Get the constant that this field is indexed with.
T getValueFromLuceneField(String documentValue)
Convert the lucene document field back to the object that you wish to use to display it.
int hashCode()
As this object is used as a key in a cache, this method must be provided and respect all internal state.

Public Methods

public boolean equals (Object obj)

As this object is used as a key in a cache, this method must be provided and respect all internal state.

See the class javadoc entry for more details.

public Comparator<T> getComparator ()

A comparator that can be used to order objects returned by getValueFromLuceneField(String).

The Comparator must be reentrant as it could be used by Lucene from multiple threads at once.

public String getDocumentConstant ()

Get the constant that this field is indexed with.

See Also

public T getValueFromLuceneField (String documentValue)

Convert the lucene document field back to the object that you wish to use to display it.

eg. '1000' -> Version 1.

This does the reverse of what com.atlassian.jira.issue.index.IssueDocument does.

For custom fields, the return value will be passed to getStatHtml(com.atlassian.jira.issue.fields.CustomField, Object, String)

Parameters
documentValue The value of the field in the lucene index
Returns
  • The value that will be passed to the display

public int hashCode ()

As this object is used as a key in a cache, this method must be provided and respect all internal state.

See the class javadoc entry for more details.