Package com.typesafe.config

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


                    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


     * contents of the current structured value (JSON array or object)
     */
    public final ConfigNodeCursor iterateChildren() {
        ConfigValue n = currentNode();
        if (n == null) throw new IllegalStateException("No current node");
        if (n.valueType() == LIST) { // false since we have already returned START_ARRAY
            return new Array((ConfigList) n, this);
        }
        if (n.valueType() == OBJECT) {
            return new Object((ConfigObject) n, this);
        }
View Full Code Here

        ConfigValue n = currentNode();
        if (n == null) throw new IllegalStateException("No current node");
        if (n.valueType() == LIST) { // false since we have already returned START_ARRAY
            return new Array((ConfigList) n, this);
        }
        if (n.valueType() == OBJECT) {
            return new Object((ConfigObject) n, this);
        }
        throw new IllegalStateException("Current node of type " + n.getClass().getName());
    }
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

        @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

        return _nodeCursor.currentNode();
    }

    protected JsonNode currentNumericNode() throws JsonParseException {
        ConfigValue configValue = currentNode();
        if ((configValue == null) || (configValue.valueType() != ConfigValueType.NUMBER)) {
            JsonToken t = (configValue == null) ? null : ConfigNodeCursor.forConfigValue(configValue);
            throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors");
        }
        Number value = (Number) configValue.unwrapped();
        if (value instanceof Double) {
View Full Code Here

        for (String label : labels) {
            if (label.charAt(0) == '_') {
                continue;
            }
            ConfigValue configValue = config.root().get(label);
            if (configValue.valueType() != ConfigValueType.STRING) {
                throw new ConfigException.WrongType(configValue.origin(), label,
                                                    "STRING", configValue.valueType().toString());
            }
            String className = (String) configValue.unwrapped();
            try {
View Full Code Here

                continue;
            }
            ConfigValue configValue = config.root().get(label);
            if (configValue.valueType() != ConfigValueType.STRING) {
                throw new ConfigException.WrongType(configValue.origin(), label,
                                                    "STRING", configValue.valueType().toString());
            }
            String className = (String) configValue.unwrapped();
            try {
                Class<?> foundClass = findAndValidateClass(className);
                mutableMap.put(label, foundClass);
View Full Code Here

        String fieldName = field.getName();
        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 = hydrateField(expectedType, fieldName, config);
                Object wrappingArray    = Array.newInstance(expectedType, 1);
                Array.set(wrappingArray, 0, singleArrayValue);
                return wrappingArray;
View Full Code Here

        for (String label : labels) {
            if (label.charAt(0) == '_') {
                continue;
            }
            ConfigValue configValue = config.root().get(label);
            if (configValue.valueType() != ConfigValueType.STRING) {
                throw new ConfigException.WrongType(configValue.origin(), label,
                                                    "STRING", configValue.valueType().toString());
            }
            String className = (String) configValue.unwrapped();
            try {
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.