aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude/IndexFactsFactory.java
blob: c2c86c5abb6aa140bea85410357d9b6358228793 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude;

import com.yahoo.config.subscription.ConfigGetter;
import com.yahoo.config.ConfigInstance;
import com.yahoo.search.config.IndexInfoConfig;
import com.yahoo.container.QrSearchersConfig;

/**
 * @author Simon Thoresen Hult
 */
public abstract class IndexFactsFactory {

    public static IndexFacts newInstance(String indexInfoConfigId) {
        return new IndexFacts(new IndexModel(resolveConfig(IndexInfoConfig.class, indexInfoConfigId),
                                             resolveConfig(QrSearchersConfig.class, null)));

    }

    @SuppressWarnings("deprecation")
    private static <T extends ConfigInstance> T resolveConfig(Class<T> configClass, String configId) {
        if (configId == null) return null;
        return ConfigGetter.getConfig(configClass, configId);
    }

}