View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.index;
20  
21  import java.util.Arrays;
22  import java.util.Comparator;
23  
24  import org.apache.lucene.search.Query;
25  import org.apache.maven.index.context.IndexingContext;
26  
27  /**
28   * A grouped search request. This kinds of request is not pageable, since order of incoming hits are not defined, hence
29   * paging between Document hits makes no sense, would produce unpredictable (and probably not meaningful) results.
30   *
31   * @see Indexer#searchGrouped(GroupedSearchRequest)
32   */
33  public class GroupedSearchRequest extends AbstractSearchRequest {
34      private Grouping grouping;
35  
36      private Comparator<String> groupKeyComparator;
37  
38      public GroupedSearchRequest(Query query, Grouping grouping) {
39          this(query, grouping, String.CASE_INSENSITIVE_ORDER);
40      }
41  
42      public GroupedSearchRequest(Query query, Grouping grouping, Comparator<String> groupKeyComparator) {
43          this(query, grouping, groupKeyComparator, null);
44      }
45  
46      public GroupedSearchRequest(Query query, Grouping grouping, IndexingContext context) {
47          this(query, grouping, String.CASE_INSENSITIVE_ORDER, context);
48      }
49  
50      public GroupedSearchRequest(
51              Query query, Grouping grouping, Comparator<String> groupKeyComparator, IndexingContext context) {
52          super(query, context != null ? Arrays.asList(context) : null);
53  
54          this.grouping = grouping;
55  
56          this.groupKeyComparator = groupKeyComparator;
57      }
58  
59      public Grouping getGrouping() {
60          return grouping;
61      }
62  
63      public void setGrouping(Grouping grouping) {
64          this.grouping = grouping;
65      }
66  
67      public Comparator<String> getGroupKeyComparator() {
68          return groupKeyComparator;
69      }
70  
71      public void setGroupKeyComparator(Comparator<String> groupKeyComparator) {
72          this.groupKeyComparator = groupKeyComparator;
73      }
74  }