1 package org.apache.lucene.facet.enhancements.params;
3 import java.util.ArrayList;
6 import org.apache.lucene.facet.enhancements.CategoryEnhancement;
7 import org.apache.lucene.facet.index.attributes.CategoryProperty;
8 import org.apache.lucene.facet.index.params.CategoryListParams;
9 import org.apache.lucene.facet.index.params.PerDimensionIndexingParams;
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed with
14 * this work for additional information regarding copyright ownership.
15 * The ASF licenses this file to You under the Apache License, Version 2.0
16 * (the "License"); you may not use this file except in compliance with
17 * the License. You may obtain a copy of the License at
19 * http://www.apache.org/licenses/LICENSE-2.0
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS,
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
29 * Default implementation of {@link EnhancementsIndexingParams}
31 * @lucene.experimental
33 public class DefaultEnhancementsIndexingParams extends
34 PerDimensionIndexingParams implements EnhancementsIndexingParams {
36 private List<CategoryEnhancement> enhancedCategories;
39 * Construct with a certain {@link CategoryEnhancement enhancement}
40 * @throws IllegalArgumentException if no enhancements are provided
42 public DefaultEnhancementsIndexingParams(CategoryEnhancement... enhancements) {
44 validateparams(enhancements);
45 addCategoryEnhancements(enhancements);
48 private void validateparams(CategoryEnhancement... enhancements) {
49 if (enhancements==null || enhancements.length<1) {
50 throw new IllegalArgumentException("at least one enhancement is required");
55 * Construct with certain {@link CategoryEnhancement enhancements}
56 * and {@link CategoryListParams}
57 * @throws IllegalArgumentException if no enhancements are provided
59 public DefaultEnhancementsIndexingParams(
60 CategoryListParams categoryListParams,
61 CategoryEnhancement... enhancements) {
62 super(categoryListParams);
63 validateparams(enhancements);
64 addCategoryEnhancements(enhancements);
67 public void addCategoryEnhancements(CategoryEnhancement... enhancements) {
68 if (enhancedCategories == null) {
69 enhancedCategories = new ArrayList<CategoryEnhancement>();
71 for (CategoryEnhancement categoryEnhancement : enhancements) {
72 enhancedCategories.add(categoryEnhancement);
76 public List<CategoryEnhancement> getCategoryEnhancements() {
77 if (enhancedCategories == null || enhancedCategories.isEmpty()) {
80 return enhancedCategories;
83 public List<Class<? extends CategoryProperty>> getRetainableProperties() {
84 if (enhancedCategories == null) {
87 List<Class<? extends CategoryProperty>> retainableProperties = new ArrayList<Class<? extends CategoryProperty>>();
88 for (CategoryEnhancement enhancement : enhancedCategories) {
89 if (enhancement.getRetainableProperty() != null) {
90 retainableProperties.add(enhancement.getRetainableProperty());
93 if (retainableProperties.isEmpty()) {
96 return retainableProperties;