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.packer;
20  
21  import java.io.File;
22  import java.util.Arrays;
23  import java.util.Collection;
24  
25  import org.apache.lucene.index.IndexReader;
26  import org.apache.maven.index.context.IndexingContext;
27  
28  import static java.util.Objects.requireNonNull;
29  
30  /**
31   * An index packing request.
32   */
33  public class IndexPackingRequest {
34      public static final int MAX_CHUNKS = 30;
35  
36      private final IndexingContext context;
37  
38      private final IndexReader indexReader;
39  
40      private final File targetDir;
41  
42      private boolean createIncrementalChunks;
43  
44      private boolean createChecksumFiles;
45  
46      private int maxIndexChunks;
47  
48      private boolean useTargetProperties;
49  
50      private Collection<IndexFormat> formats;
51  
52      public IndexPackingRequest(final IndexingContext context, final IndexReader indexReader, final File targetDir) {
53          this.context = requireNonNull(context);
54  
55          this.indexReader = requireNonNull(indexReader);
56  
57          this.targetDir = requireNonNull(targetDir);
58  
59          this.createIncrementalChunks = true;
60  
61          this.createChecksumFiles = false;
62  
63          this.maxIndexChunks = MAX_CHUNKS;
64  
65          this.useTargetProperties = false;
66  
67          this.formats = Arrays.asList(IndexFormat.FORMAT_V1);
68      }
69  
70      public IndexingContext getContext() {
71          return context;
72      }
73  
74      public IndexReader getIndexReader() {
75          return indexReader;
76      }
77  
78      /**
79       * Sets index formats to be created
80       */
81      public void setFormats(Collection<IndexFormat> formats) {
82          this.formats = formats;
83      }
84  
85      /**
86       * Returns index formats to be created.
87       */
88      public Collection<IndexFormat> getFormats() {
89          return formats;
90      }
91  
92      public File getTargetDir() {
93          return targetDir;
94      }
95  
96      public boolean isCreateIncrementalChunks() {
97          return createIncrementalChunks;
98      }
99  
100     public void setCreateIncrementalChunks(boolean createIncrementalChunks) {
101         this.createIncrementalChunks = createIncrementalChunks;
102     }
103 
104     public boolean isCreateChecksumFiles() {
105         return createChecksumFiles;
106     }
107 
108     public void setCreateChecksumFiles(boolean createChecksumFiles) {
109         this.createChecksumFiles = createChecksumFiles;
110     }
111 
112     public int getMaxIndexChunks() {
113         return maxIndexChunks;
114     }
115 
116     public void setMaxIndexChunks(int maxIndexChunks) {
117         this.maxIndexChunks = maxIndexChunks;
118     }
119 
120     public boolean isUseTargetProperties() {
121         return useTargetProperties;
122     }
123 
124     public void setUseTargetProperties(boolean useTargetProperties) {
125         this.useTargetProperties = useTargetProperties;
126     }
127 
128     /**
129      * Index format enumeration.
130      */
131     public enum IndexFormat {
132         FORMAT_V1
133     }
134 }