All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.schema.ImportedFieldsEnumerator Maven / Gradle / Ivy

There is a newer version: 8.441.21
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema;

import com.yahoo.schema.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 schemas;

    public ImportedFieldsEnumerator(Collection 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);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy