blob: 512cae5021aefbcd7da1efbbb8d0030d1789f584 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;
import com.yahoo.searchdefinition.document.SDDocumentType;
import java.util.Collection;
/**
* Enumerates and emplaces a set of all imported fields into a SDDocumentType from
* its corresponding Search instance.
*/
public class ImportedFieldsEnumerator {
private final Collection<Schema> schemas;
public ImportedFieldsEnumerator(Collection<Schema> schemas) {
this.schemas = schemas;
}
public void enumerateImportedFields(SDDocumentType documentType) {
var search = this.schemas.stream()
.filter(s -> s.getDocument() != null)
.filter(s -> s.getDocument().getName().equals(documentType.getName()))
.findFirst();
if (search.isEmpty()) {
return; // No imported fields present.
}
search.get().temporaryImportedFields().ifPresent(documentType::setTemporaryImportedFields);
}
}
|