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.examples.indexing;
20  
21  import javax.inject.Inject;
22  import javax.inject.Named;
23  import javax.inject.Singleton;
24  
25  import java.util.ArrayList;
26  import java.util.List;
27  import java.util.Map;
28  
29  import org.apache.maven.index.Indexer;
30  import org.apache.maven.index.Scanner;
31  import org.apache.maven.index.context.IndexCreator;
32  
33  /**
34   * A simple configuration holder class.
35   * This class contains the mapped indexers.
36   *
37   * @author mtodorov
38   */
39  @Named
40  @Singleton
41  public class IndexerConfiguration {
42  
43      private Indexer indexer;
44  
45      private Scanner scanner;
46  
47      private Map<String, IndexCreator> indexers;
48  
49      @Inject
50      public IndexerConfiguration(Indexer indexer, Scanner scanner, Map<String, IndexCreator> indexers) {
51          this.indexer = indexer;
52          this.scanner = scanner;
53          this.indexers = indexers;
54      }
55  
56      public List<IndexCreator> getIndexersAsList() {
57          return indexers == null ? new ArrayList<>(0) : new ArrayList<>(indexers.values());
58      }
59  
60      public Indexer getIndexer() {
61          return indexer;
62      }
63  
64      public void setIndexer(Indexer indexer) {
65          this.indexer = indexer;
66      }
67  
68      public Scanner getScanner() {
69          return scanner;
70      }
71  
72      public void setScanner(Scanner scanner) {
73          this.scanner = scanner;
74      }
75  
76      public Map<String, IndexCreator> getIndexers() {
77          return indexers;
78      }
79  
80      public void setIndexers(Map<String, IndexCreator> indexers) {
81          this.indexers = indexers;
82      }
83  }