diff --git a/modules/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java b/modules/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java index fced0cf7393..90c4726d49d 100644 --- a/modules/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java +++ b/modules/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java @@ -47,24 +47,24 @@ import org.apache.lucene.facet.taxonomy.TaxonomyWriter; * @lucene.experimental */ public interface CategoryEnhancement { - + /** * Get the bytes to be added to the category token payload for this * enhancement. *
- * NOTE: The returned array is copied, it is recommended to allocate - * a new one each time. + * NOTE: The returned array is copied, it is recommended to allocate a + * new one each time. *
* The bytes generated by this method are the input of * {@link #extractCategoryTokenData(byte[], int, int)}. * * @param categoryAttribute - * The attribute of the category. + * The attribute of the category. * @return The bytes to be added to the category token payload for this * enhancement. */ byte[] getCategoryTokenBytes(CategoryAttribute categoryAttribute); - + /** * Get the data of this enhancement from a category token payload. *
@@ -72,56 +72,61 @@ public interface CategoryEnhancement { * {@link #getCategoryTokenBytes(CategoryAttribute)}. * * @param buffer - * The payload buffer. + * The payload buffer. * @param offset - * The offset of this enhancement's data in the buffer. + * The offset of this enhancement's data in the buffer. * @param length - * The length of this enhancement's data (bytes). + * The length of this enhancement's data (bytes). * @return An Object containing the data. */ Object extractCategoryTokenData(byte[] buffer, int offset, int length); - + /** - * Declarative method to indicate whether this enhancement generates - * separate category list. + * Declarative method to indicate whether this enhancement generates separate + * category list. * * @return {@code true} if generates category list, else {@code false}. */ boolean generatesCategoryList(); - + /** * Returns the text of this enhancement's category list term. * * @return The text of this enhancement's category list term. */ String getCategoryListTermText(); - + /** - * Get the {@link CategoryListTokenizer} which generates the category list - * for this enhancement. If {@link #generatesCategoryList()} returns - * {@code false} this method will not be called. + * Get the {@link CategoryListTokenizer} which generates the category list for + * this enhancement. If {@link #generatesCategoryList()} returns {@code false} + * this method will not be called. * * @param tokenizer - * The input stream containing categories. + * The input stream containing categories. * @param indexingParams - * The indexing params to use. + * The indexing params to use. * @param taxonomyWriter - * The taxonomy to add categories and get their ordinals. + * The taxonomy to add categories and get their ordinals. * @return A {@link CategoryListTokenizer} generating the category list for * this enhancement, with {@code tokenizer} as it's input. */ CategoryListTokenizer getCategoryListTokenizer(TokenStream tokenizer, - EnhancementsIndexingParams indexingParams, - TaxonomyWriter taxonomyWriter); - + EnhancementsIndexingParams indexingParams, TaxonomyWriter taxonomyWriter); + /** * Get a {@link CategoryProperty} class to be retained when creating * {@link CategoryParentsStream}. * * @return the {@link CategoryProperty} class to be retained when creating - * {@link CategoryParentsStream}, or {@code null} if there is no - * such property. + * {@link CategoryParentsStream}, or {@code null} if there is no such + * property. */ Class extends CategoryProperty> getRetainableProperty(); - + + /** + * Category enhancements must override {@link Object#equals(Object)}, as it is + * used in + * {@link EnhancementsPayloadIterator#getCategoryData(CategoryEnhancement)}. + */ + public boolean equals(Object o); } diff --git a/modules/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java b/modules/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java index db965c10e10..8fc0d1be242 100644 --- a/modules/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java +++ b/modules/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java @@ -150,4 +150,17 @@ public class AssociationEnhancement implements CategoryEnhancement { return null; } + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + return (o instanceof AssociationEnhancement); + } + + @Override + public int hashCode() { + return super.hashCode(); + } + }