當前位置: 首頁>>代碼示例>>Java>>正文


Java ConfigObject.toConfig方法代碼示例

本文整理匯總了Java中com.typesafe.config.ConfigObject.toConfig方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigObject.toConfig方法的具體用法?Java ConfigObject.toConfig怎麽用?Java ConfigObject.toConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.typesafe.config.ConfigObject的用法示例。


在下文中一共展示了ConfigObject.toConfig方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRpcModules

import com.typesafe.config.ConfigObject; //導入方法依賴的package包/類
public List<ModuleDescription> getRpcModules() {
    if (this.moduleDescriptions != null) {
        return this.moduleDescriptions;
    }

    List<ModuleDescription> modules = new ArrayList<>();

    if (!configFromFiles.hasPath("rpc.modules")) {
        return modules;
    }

    List<? extends ConfigObject> list = configFromFiles.getObjectList("rpc.modules");

    for (ConfigObject configObject : list) {
        Config configElement = configObject.toConfig();
        String name = configElement.getString("name");
        String version = configElement.getString("version");
        boolean enabled = configElement.getBoolean("enabled");
        List<String> enabledMethods = null;
        List<String> disabledMethods = null;

        if (configElement.hasPath("methods.enabled")) {
            enabledMethods = configElement.getStringList("methods.enabled");
        }

        if (configElement.hasPath("methods.disabled")) {
            disabledMethods = configElement.getStringList("methods.disabled");
        }

        modules.add(new ModuleDescription(name, version, enabled, enabledMethods, disabledMethods));
    }

    this.moduleDescriptions = modules;

    return modules;
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:37,代碼來源:RskSystemProperties.java

示例2: fromConfig

import com.typesafe.config.ConfigObject; //導入方法依賴的package包/類
/**
 * Get the instruments from a configuration object.
 *
 * @param config a configuration object
 * @param path the path expression
 * @return the instruments
 * @throws ConfigException if a configuration error occurs
 */
public static Instruments fromConfig(Config config, String path) {
    ConfigObject root = config.getObject(path);

    Config rootConfig = root.toConfig();

    int priceIntegerDigits = getInt(rootConfig, "price-integer-digits", 1);
    int sizeIntegerDigits  = getInt(rootConfig, "size-integer-digits",  1);

    Set<String> instruments = root.keySet();

    instruments.remove("price-integer-digits");
    instruments.remove("size-integer-digits");

    List<Instrument> values = new ArrayList<>();

    for (String instrument : instruments)
        values.add(Instrument.fromConfig(rootConfig, instrument));

    int maxPriceFractionDigits = max(values, Instrument::getPriceFractionDigits);
    int maxSizeFractionDigits  = max(values, Instrument::getSizeFractionDigits);

    for (Instrument value : values) {
        value.setPriceFormat(priceIntegerDigits, maxPriceFractionDigits);
        value.setSizeFormat(sizeIntegerDigits, maxSizeFractionDigits);
    }

    return new Instruments(values, priceIntegerDigits, maxPriceFractionDigits,
            sizeIntegerDigits, maxSizeFractionDigits);
}
 
開發者ID:paritytrading,項目名稱:parity,代碼行數:38,代碼來源:Instruments.java

示例3: groupPanels

import com.typesafe.config.ConfigObject; //導入方法依賴的package包/類
private void groupPanels() {

        Config config = Lookup.getConfig();
        ConfigObject groups = config.getObject("vars.query.column.groups");
        Config groupsConfig = groups.toConfig();

        List<AbstractValuePanel> vps = new ArrayList<>(valuePanels);
        List<AbstractValuePanel> used = new ArrayList<>();

        Set<String> groupNames = groups.keySet();
        for (String name : groupNames) {
            formLayout.addHeader(name);
            List<String> columns = groupsConfig.getStringList(name);
            List<AbstractValuePanel> matchingVps = vps.stream()
                    .filter(vp -> columns.contains(vp.getValueName()))
                    .sorted((vp1, vp2) ->
                            vp1.getValueName().toUpperCase().compareTo(vp2.getValueName().toUpperCase()))
                    .collect(Collectors.toList());

            matchingVps.stream().forEach(vp ->
                        formLayout.add(new EditorFormRow<>(vp.getTitle(), vp)));

            used.addAll(matchingVps);
        }

        vps.removeAll(used);
        if (!vps.isEmpty()) {
            formLayout.addHeader("Other");
            vps.stream().forEach(vp -> formLayout.add(new EditorFormRow<>(vp.getTitle(), vp)));
        }

    }
 
開發者ID:hohonuuli,項目名稱:vars,代碼行數:33,代碼來源:AdvancedSearchWorkbench.java

示例4: parseConfiguration

import com.typesafe.config.ConfigObject; //導入方法依賴的package包/類
public static BenchmarkPlan parseConfiguration(String configurationFile) throws InvalidConfigurationException {
    try {
        Config config = ConfigFactory.parseFile(new File(configurationFile));
        ConfigObject elasticsearchConfig = config.getObject("elasticsearch");
        List<? extends ConfigObject> stepsConfig = config.getObjectList("steps");

        ObjectMapper objectMapper = new ObjectMapper();

        // Parse elasticsearch configuration
        ElasticsearchConfiguration esConfig = objectMapper.convertValue(elasticsearchConfig.unwrapped(), ElasticsearchConfiguration.class);
        esConfig.validateConfig();

        // Build initial benchmark plan
        BenchmarkPlan benchmarkPlan = new BenchmarkPlan(esConfig);

        for (ConfigObject currConfigObject: stepsConfig) {

            Config currConfig = currConfigObject.toConfig();

            long duration = currConfig.getDuration("duration").toMillis();
            BenchmarkStep step = new BenchmarkStep(duration);

            if (currConfig.hasPath("indexing")) {
                IndexingConfiguration indexingConfig = objectMapper.convertValue(currConfig.getObject("indexing").unwrapped(), IndexingConfiguration.class);
                indexingConfig.validateConfig();
                step.addController(new IndexingController(indexingConfig, benchmarkPlan.getEsController()));
            }

            if (currConfig.hasPath("search")) {
                SearchConfiguration searchConfig = objectMapper.convertValue(currConfig.getObject("search").unwrapped(), SearchConfiguration.class);
                searchConfig.validateConfig();
                step.addController(new SearchController(searchConfig, benchmarkPlan.getEsController()));
            }

            if (currConfig.hasPath("optimize")) {
                OptimizeConfiguration optimizeConfig = objectMapper.convertValue(currConfig.getObject("optimize").unwrapped(), OptimizeConfiguration.class);
                optimizeConfig.validateConfig();
                step.addController(new OptimizeController(optimizeConfig, benchmarkPlan.getEsController()));
            }

            if (currConfig.hasPath("noop")) {
                step.addController(new NoopController());
            }

            // Adding the final step
            benchmarkPlan.addStep(step);
        }

        return benchmarkPlan;

    } catch (ConfigException e) {
        throw new RuntimeException("Could not parse configuration file!", e);
    }
}
 
開發者ID:logzio,項目名稱:elasticsearch-benchmark-tool,代碼行數:55,代碼來源:ConfigurationParser.java

示例5: CodableClassInfo

import com.typesafe.config.ConfigObject; //導入方法依賴的package包/類
public CodableClassInfo(@Nonnull Class<?> clazz,
                        @Nonnull Config globalDefaults,
                        @Nonnull PluginRegistry pluginRegistry) {

    // skip native classes
    if (Fields.isNative(clazz) || clazz.isArray()) {
        classData = ImmutableSortedMap.of();
        baseClass = clazz;
        pluginMap = PluginMap.EMPTY;
        fieldDefaults = ConfigFactory.empty();
        return;
    }

    // find any parent class (or itself) with a Pluggable annotation
    Class<?> findBaseClass = clazz;
    PluginMap findPluginMap = PluginMap.EMPTY;

    Class<?> ptr = clazz;
    while (ptr != null) {
        if (pluginRegistry.byClass().containsKey(ptr)) {
            findPluginMap = pluginRegistry.byClass().get(ptr);
            findBaseClass = ptr;
            break;
        }
        Pluggable pluggable = ptr.getAnnotation(Pluggable.class);
        if (pluggable != null) {
            String category = pluggable.value();
            findPluginMap = pluginRegistry.asMap().get(category);
            findBaseClass = ptr;
            if (findPluginMap == null) {
                log.warn("missing plugin map for {}, reached from {}", ptr, clazz);
                findPluginMap = PluginMap.EMPTY;
            }
            break;
        }
        ptr = ptr.getSuperclass();
    }
    pluginMap = findPluginMap;
    baseClass = findBaseClass;

    // find all fields in the class and its parent classes, and aggregate any defaults
    Map<String, Field> fields = new HashMap<>();
    // slower than using unwrapped, mutable conversions but this preserves origins
    ConfigObject buildDefaults = ConfigFactory.empty().root();

    Class<?> ptrForFields = clazz;
    while (ptrForFields != null) {
        String canonicalClassName = ptrForFields.getCanonicalName();
        ConfigObject classDefaults;
        if ((canonicalClassName != null) && globalDefaults.hasPath(canonicalClassName)) {
            classDefaults = globalDefaults.getObject(canonicalClassName);
        } else {
            classDefaults = ConfigFactory.empty().root();
        }
        for (Field field : ptrForFields.getDeclaredFields()) {
            if (fields.get(field.getName()) == null) {
                fields.put(field.getName(), field);
            } else {
                classDefaults = classDefaults.withoutKey(field.getName());
                log.debug("({}) ignoring field in parent class ({}) with duplicate name ({})",
                          clazz, ptrForFields, field.getName());
            }
        }
        for (Map.Entry<String, ConfigValue> pair : classDefaults.entrySet()) {
            if (!buildDefaults.containsKey(pair.getKey())) {
                buildDefaults = buildDefaults.withValue(pair.getKey(), pair.getValue());
            }
        }
        ptrForFields = ptrForFields.getSuperclass();
    }
    fieldDefaults = buildDefaults.toConfig();

    // turn all the found fields into CodableFieldInfo objects
    Map<String, CodableFieldInfo> buildClassData = buildFieldInfoMap(fields.values());
    classData = ImmutableSortedMap.<String, CodableFieldInfo>naturalOrder()
                                  .putAll(buildClassData).build();
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:78,代碼來源:CodableClassInfo.java


注:本文中的com.typesafe.config.ConfigObject.toConfig方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。