@PublicSpi
public interface LuceneFieldSorter<T>
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 Object.equals(Object)
and Object.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.
Modifier and Type | Method and Description |
---|---|
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.
|
String getDocumentConstant()
CustomFieldSearcher
T getValueFromLuceneField(String documentValue)
eg. '1000' -> Version 1.
For custom fields, the return value will be passed to
CustomFieldSearcherModuleDescriptor.getStatHtml(com.atlassian.jira.issue.fields.CustomField, Object, String)
documentValue
- The value of the field in the lucene indexComparator<T> getComparator()
getValueFromLuceneField(String)
.
The Comparator must be reentrant as it could be used by Lucene from multiple threads at once.
boolean equals(Object obj)
See the class javadoc entry for more details.
Copyright © 2002-2022 Atlassian. All Rights Reserved.