summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java
blob: 2e4a41b70d562033a40f06a9ac922e0d10e6f7dd (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
33
34
35
36
37
38
39
40
41
42
43
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model.deploy;

import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SchemaBuilder;
import com.yahoo.vespa.documentmodel.DocumentModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Internal helper class to retrieve document model and schemas.
 *
 * @author Ulf Lilleengen
 */
// TODO: This should be removed in favor of Application
public class SearchDocumentModel {

    private final DocumentModel documentModel;
    private final List<Schema> schemas;

    public SearchDocumentModel(DocumentModel documentModel, List<Schema> schemas) {
        this.documentModel = documentModel;
        this.schemas = schemas;
    }

    public DocumentModel getDocumentModel() {
        return documentModel;
    }

    public List<Schema> getSchemas() {
        return schemas;
    }

    public static SearchDocumentModel fromBuilder(SchemaBuilder builder) {
        List<Schema> ret = new ArrayList<>();
        for (Schema schema : builder.getSchemaList()) {
            ret.add(schema);
        }
        return new SearchDocumentModel(builder.getModel(), ret);
    }

}