Package com.typesafe.config

Examples of com.typesafe.config.Config.root()


            Config aliasDefaults = pluginMap.aliasDefaults("_array").toConfig();
            String arrayField = aliasDefaults.getString("_primary");
            try {
                ObjectNode objectFieldValues = (ObjectNode) objectCodec.createObjectNode();
                Jackson.setAt(objectFieldValues, arrayNode, arrayField);
                ObjectNode aliasFieldDefaults = Jackson.configConverter(aliasDefaults.root());
                Jackson.merge(objectFieldValues, aliasFieldDefaults);
                JsonDeserializer<Object> deser = _findDeserializer(ctxt, "_array");
                JsonParser treeParser = objectCodec.treeAsTokens(objectFieldValues);
                treeParser.nextToken();
                return deser.deserialize(treeParser, ctxt);
View Full Code Here


            }
        }
        Class vc = (Class) field.getGenericTypes()[1];
        boolean va = field.isMapValueArray();
        Config configMap = config.getConfig(field.getName());
        for (Map.Entry<String, ConfigValue> entry : configMap.root().entrySet()) {
            String key = entry.getKey();
            if (field.isInterned()) {
                key = key.intern();
            }
            // control for map keys that might have unexpected behavior when parsed as paths
View Full Code Here

    /** given a class, instance, and config.. turn config values into field values */
    private void populateObjectFields(CodableClassInfo classInfo, Object objectShell, Config config) {
        Config fieldDefaults = classInfo.getFieldDefaults();
        if (objectShell instanceof ConfigCodable) {
            ((ConfigCodable) objectShell).fromConfigObject(config.root(), fieldDefaults.root());
            return;
        }
        Collection<String> unusedKeys = new HashSet<>(config.root().keySet());
        for (CodableFieldInfo field : classInfo.values()) {
            if (field.isWriteOnly()) {
View Full Code Here

     */
    public <T> T decodeObject(@Nonnull String category, @Language("HOCON") @Nonnull String configText) {
        PluginMap pluginMap = Preconditions.checkNotNull(pluginRegistry.asMap().get(category),
                                                         "could not find anything about the category %s", category);
        Config config = ConfigFactory.parseString(configText).resolve();
        return hydrateObject(null, pluginMap, null, config.root());
    }

    /**
     * Instantiate an object without a compile time expected type. This expects a config of the
     * form "{plugin-category: {...}}". ie. there should be exactly one top level key and that
View Full Code Here

                if (ValueCodable.class.isAssignableFrom(type)) {
                    try {
                        T objectShell = type.newInstance();
                        CodableClassInfo configInfo = (info != null) ? info : getOrCreateClassInfo(type);
                        Config fieldDefaults = configInfo.getFieldDefaults();
                        ((ValueCodable) objectShell).fromConfigValue(configValue, fieldDefaults.root());
                        if (objectShell instanceof SuperCodable) {
                            ((SuperCodable) objectShell).postDecode();
                        }
                        return objectShell;
                    } catch (InstantiationException | IllegalAccessException | RuntimeException ex) {
View Full Code Here

            }
        }
        Class vc = (Class) field.getGenericTypes()[1];
        boolean va = field.isMapValueArray();
        Config configMap = config.getConfig(field.getName());
        for (Map.Entry<String, ConfigValue> entry : configMap.root().entrySet()) {
            String key = entry.getKey();
            if (field.isInterned()) {
                key = key.intern();
            }
            // control for map keys that might have unexpected behavior when parsed as paths
View Full Code Here

    public PluginRegistry(Config config) {
        Config defaultPluginMapSettings = config.getConfig(PLUGIN_DEFAULTS_PATH);
        String pluginPath = config.getString(PLUGINS_PATH_PATH);
        Config pluginConfigs = config.getConfig(pluginPath);

        Set<String> categories = pluginConfigs.root().keySet();
        Map<String, PluginMap> mapsFromConfig = new HashMap<>(categories.size());
        BiMap<Class<?>, PluginMap> mapsFromConfigByClass = HashBiMap.create(categories.size());
        for (String category : categories) {
            Config pluginConfig = pluginConfigs.getConfig(category)
                                               .withFallback(defaultPluginMapSettings);
View Full Code Here

            Config aliasDefaults = pluginMap.aliasDefaults("_array").toConfig();
            String arrayField = aliasDefaults.getString("_primary");
            try {
                ObjectNode objectFieldValues = (ObjectNode) objectCodec.createObjectNode();
                Jackson.setAt(objectFieldValues, arrayNode, arrayField);
                ObjectNode aliasFieldDefaults = Jackson.configConverter(aliasDefaults.root());
                Jackson.merge(objectFieldValues, aliasFieldDefaults);
                JsonDeserializer<Object> deser = _findDeserializer(ctxt, "_array");
                JsonParser treeParser = objectCodec.treeAsTokens(objectFieldValues);
                treeParser.nextToken();
                return deser.deserialize(treeParser, ctxt);
View Full Code Here

     */
    public <T> T decodeObject(@Nonnull String category, @Syntax("HOCON") @Nonnull String configText) {
        PluginMap pluginMap = Preconditions.checkNotNull(pluginRegistry.asMap().get(category),
                                                         "could not find anything about the category %s", category);
        Config config = ConfigFactory.parseString(configText).resolve();
        return hydrateObject(null, pluginMap, null, config.root());
    }

    /**
     * Instantiate an object without a compile time expected type. This expects a config of the
     * form "{plugin-category: {...}}". ie. there should be exactly one top level key and that
View Full Code Here

                if (ValueCodable.class.isAssignableFrom(type)) {
                    try {
                        T objectShell = type.newInstance();
                        CodableClassInfo configInfo = (info != null) ? info : getOrCreateClassInfo(type);
                        Config fieldDefaults = configInfo.getFieldDefaults();
                        ((ValueCodable) objectShell).fromConfigValue(configValue, fieldDefaults.root());
                        if (objectShell instanceof SuperCodable) {
                            ((SuperCodable) objectShell).postDecode();
                        }
                        return objectShell;
                    } catch (InstantiationException | IllegalAccessException | RuntimeException ex) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.