Package com.typesafe.config

Examples of com.typesafe.config.ConfigValue.valueType()


        @Override
        public boolean currentHasChildren() {
            // note: ONLY to be called for container nodes
            ConfigValue currentValue = currentNode();
            if (currentValue.valueType() == ConfigValueType.LIST) {
                return !((ConfigList) currentValue).isEmpty();
            } else {
                return !((ConfigObject) currentValue).isEmpty();
            }
        }
View Full Code Here


        @Override
        public boolean currentHasChildren() {
            // note: ONLY to be called for container nodes
            ConfigValue currentValue = currentNode();
            if (currentValue.valueType() == ConfigValueType.LIST) {
                return !((ConfigList) currentValue).isEmpty();
            } else {
                return !((ConfigObject) currentValue).isEmpty();
            }
        }
View Full Code Here

                                                " for " + pluginMap);
        }
        ConfigObject root = (ConfigObject) configValue;
        ConfigValue classValue = root.get(classField);
        // normal, explicit typing
        if ((classValue != null) && (classValue.valueType() == ConfigValueType.STRING)) {
            String classValueString = (String) classValue.unwrapped();
            ConfigObject aliasDefaults = pluginMap.aliasDefaults(classValueString);
            return root.withFallback(aliasDefaults);
        }
View Full Code Here

                String onlyKey = root.keySet().iterator().next();
                try {
                    pluginMap.getClass(onlyKey); // make sure key is a valid type
                    ConfigValue onlyKeyValue = root.values().iterator().next();
                    ConfigObject aliasDefaults = pluginMap.aliasDefaults(onlyKey);
                    if (onlyKeyValue.valueType() != ConfigValueType.OBJECT) {
                        if (aliasDefaults.get("_primary") != null) {
                            onlyKeyValue = onlyKeyValue.atPath((String) aliasDefaults.get("_primary").unwrapped()).root();
                        } else {
                            throw new ConfigException.WrongType(onlyKeyValue.origin(), onlyKey,
                                                                "OBJECT", onlyKeyValue.valueType().toString());
View Full Code Here

                    if (onlyKeyValue.valueType() != ConfigValueType.OBJECT) {
                        if (aliasDefaults.get("_primary") != null) {
                            onlyKeyValue = onlyKeyValue.atPath((String) aliasDefaults.get("_primary").unwrapped()).root();
                        } else {
                            throw new ConfigException.WrongType(onlyKeyValue.origin(), onlyKey,
                                                                "OBJECT", onlyKeyValue.valueType().toString());
                        }
                    }
                    ConfigObject fieldValues = (ConfigObject) onlyKeyValue;
                    return fieldValues.withValue(classField, ConfigValueFactory.fromAnyRef(
                            onlyKey, "single key to type from " + root.origin().description()))
View Full Code Here

            if (!((label.charAt(0) != '_') || "_array".equals(label) || "_default".equals(label))) {
                continue;
            }
            ConfigValue configValue = config.root().get(label);
            String className;
            if (configValue.valueType() == ConfigValueType.STRING) {
                className = (String) configValue.unwrapped();
            } else if (configValue.valueType() == ConfigValueType.OBJECT) {
                ConfigObject configObject = (ConfigObject) configValue;
                className = configObject.toConfig().getString("_class");
                if (configObject.toConfig().hasPath("_inline") &&
View Full Code Here

            }
            ConfigValue configValue = config.root().get(label);
            String className;
            if (configValue.valueType() == ConfigValueType.STRING) {
                className = (String) configValue.unwrapped();
            } else if (configValue.valueType() == ConfigValueType.OBJECT) {
                ConfigObject configObject = (ConfigObject) configValue;
                className = configObject.toConfig().getString("_class");
                if (configObject.toConfig().hasPath("_inline") &&
                        configObject.toConfig().getBoolean("_inline")) {
                    mutableInlinedAliasSet.add(label);
View Full Code Here

                        configObject.toConfig().getBoolean("_inline")) {
                    mutableInlinedAliasSet.add(label);
                }
            } else {
                throw new ConfigException.WrongType(configValue.origin(), label,
                                                    "STRING OR OBJECT", configValue.valueType().toString());
            }
            if (labels.contains(className)) {
                // points to another alias
                mutableAliasMap.put(label, className);
            } else {
View Full Code Here

    }

    @Nonnull public ConfigObject aliasDefaults(String alias) {
        ConfigValue configValue = config.root().get(alias);
        ConfigObject defaults;
        if ((configValue != null) && (configValue.valueType() == ConfigValueType.OBJECT)) {
            defaults = (ConfigObject) configValue;
        } else {
            defaults = ConfigFactory.empty().root();
        }
        String aliasTarget = aliases.get(alias);
View Full Code Here

            return config.root().get(fieldName);
        } else if (!config.hasPath(fieldName)) {
            return null;
        } else if (field.isArray()) { // check CodableFieldInfo instead of expectedType
            ConfigValue configValue = config.root().get(fieldName);
            if ((configValue.valueType() != ConfigValueType.LIST) &&
                field.autoArrayEnabled()) {
                Object singleArrayValue = hydrateFieldComponent(expectedType, fieldName, config);
                Object wrappingArray    = Array.newInstance(expectedType, 1);
                Array.set(wrappingArray, 0, singleArrayValue);
                return wrappingArray;
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.