blob: 91fd0aee957c9b72cc1e46201cbf1c47444bbb50 (
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
32
|
// Copyright 2020 Oath Inc. 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;
import java.util.List;
/**
* Enumerates and emplaces a set of all imported fields into a SDDocumentType from
* its corresponding Search instance.
*/
public class ImportedFieldsEnumerator {
private final Collection<Search> schemas;
public ImportedFieldsEnumerator(Collection<Search> 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);
}
}
|