1
package org.apache.lucene.document;
5
* Copyright 2004 The Apache Software Foundation
7
* Licensed under the Apache License, Version 2.0 (the "License");
8
* you may not use this file except in compliance with the License.
9
* You may obtain a copy of the License at
11
* http://www.apache.org/licenses/LICENSE-2.0
13
* Unless required by applicable law or agreed to in writing, software
14
* distributed under the License is distributed on an "AS IS" BASIS,
15
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
* See the License for the specific language governing permissions and
17
* limitations under the License.
21
* Declare what fields to load normally and what fields to load lazily
24
public class SetBasedFieldSelector implements FieldSelector {
26
private Set<String> fieldsToLoad;
27
private Set<String> lazyFieldsToLoad;
30
* Pass in the Set of {@link Field} names to load and the Set of {@link Field} names to load lazily. If both are null, the
31
* Document will not have any {@link Field} on it.
32
* @param fieldsToLoad A Set of {@link String} field names to load. May be empty, but not null
33
* @param lazyFieldsToLoad A Set of {@link String} field names to load lazily. May be empty, but not null
35
public SetBasedFieldSelector(Set<String> fieldsToLoad, Set<String> lazyFieldsToLoad) {
36
this.fieldsToLoad = fieldsToLoad;
37
this.lazyFieldsToLoad = lazyFieldsToLoad;
41
* Indicate whether to load the field with the given name or not. If the {@link Field#name()} is not in either of the
42
* initializing Sets, then {@link org.apache.lucene.document.FieldSelectorResult#NO_LOAD} is returned. If a Field name
43
* is in both <code>fieldsToLoad</code> and <code>lazyFieldsToLoad</code>, lazy has precedence.
45
* @param fieldName The {@link Field} name to check
46
* @return The {@link FieldSelectorResult}
48
public FieldSelectorResult accept(String fieldName) {
49
FieldSelectorResult result = FieldSelectorResult.NO_LOAD;
50
if (fieldsToLoad.contains(fieldName) == true){
51
result = FieldSelectorResult.LOAD;
53
if (lazyFieldsToLoad.contains(fieldName) == true){
54
result = FieldSelectorResult.LAZY_LOAD;
b'\\ No newline at end of file'