Package com.typesafe.config

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


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


        /** look for normal, explicit type syntax. ie. "{type: my-type, val: my-val}" */
        String classField = pluginMap.classField();
        ConfigValue typeValue = configObject.get(classField);
        if (typeValue != null) {
            if (typeValue.valueType() != ConfigValueType.STRING) {
                throw new ConfigException.WrongType(typeValue.origin(), classField,
                                                    "STRING", typeValue.valueType().toString());
            }
            String stype = (String) typeValue.unwrapped();
            try {
View Full Code Here

        String classField = pluginMap.classField();
        ConfigValue typeValue = configObject.get(classField);
        if (typeValue != null) {
            if (typeValue.valueType() != ConfigValueType.STRING) {
                throw new ConfigException.WrongType(typeValue.origin(), classField,
                                                    "STRING", typeValue.valueType().toString());
            }
            String stype = (String) typeValue.unwrapped();
            try {
                Class<T> normalType = (Class<T>) pluginMap.getClass(stype);
                ConfigObject aliasDefaults = pluginMap.aliasDefaults(stype);
View Full Code Here

                try {
                    Class<T> singleKeyType = (Class<T>) pluginMap.getClass(sugarType);
                    ConfigObject aliasDefaults = pluginMap.aliasDefaults(sugarType);
                    ConfigValue configValue = configObject.get(sugarType);
                    // if value is not an object, try supporting _primary syntax to derive one
                    if (configValue.valueType() != ConfigValueType.OBJECT) {
                        if (aliasDefaults.get("_primary") != null) {
                            configValue = configValue.atPath((String) aliasDefaults.get("_primary").unwrapped()).root();
                        } else {
                            throw new ConfigException.WrongType(configValue.origin(), sugarType,
                                                                "OBJECT", configValue.valueType().toString());
View Full Code Here

                    if (configValue.valueType() != ConfigValueType.OBJECT) {
                        if (aliasDefaults.get("_primary") != null) {
                            configValue = configValue.atPath((String) aliasDefaults.get("_primary").unwrapped()).root();
                        } else {
                            throw new ConfigException.WrongType(configValue.origin(), sugarType,
                                                                "OBJECT", configValue.valueType().toString());
                        }
                    }
                    ConfigObject fieldValues = ((ConfigObject) configValue).withFallback(aliasDefaults);
                    CodableClassInfo singleKeyInfo = getOrCreateClassInfo(singleKeyType);
                    return createAndPopulate(singleKeyInfo, singleKeyType, fieldValues);
View Full Code Here

                                                " for " + pluginMap);
        }
        ConfigObject root = (ConfigObject) objectOrArray;
        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 configValue = root.values().iterator().next();
                    ConfigObject aliasDefaults = pluginMap.aliasDefaults(onlyKey);
                    if (configValue.valueType() != ConfigValueType.OBJECT) {
                        if (aliasDefaults.get("_primary") != null) {
                            configValue = configValue.atPath((String) aliasDefaults.get("_primary").unwrapped()).root();
                        } else {
                            throw new ConfigException.WrongType(configValue.origin(), onlyKey,
                                                                "OBJECT", configValue.valueType().toString());
View Full Code Here

                    if (configValue.valueType() != ConfigValueType.OBJECT) {
                        if (aliasDefaults.get("_primary") != null) {
                            configValue = configValue.atPath((String) aliasDefaults.get("_primary").unwrapped()).root();
                        } else {
                            throw new ConfigException.WrongType(configValue.origin(), onlyKey,
                                                                "OBJECT", configValue.valueType().toString());
                        }
                    }
                    ConfigObject fieldValues = (ConfigObject) configValue;
                    return fieldValues.withValue(classField, ConfigValueFactory.fromAnyRef(
                            onlyKey, "single key to type from " + root.origin().description()))
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

        /* look for normal, explicit type syntax. ie. "{type: my-type, val: my-val}" */
        String classField = pluginMap.classField();
        ConfigValue typeValue = configObject.get(classField);
        if (typeValue != null) {
            if (typeValue.valueType() != ConfigValueType.STRING) {
                throw new ConfigException.WrongType(typeValue.origin(), classField,
                                                    "STRING", typeValue.valueType().toString());
            }
            String stype = (String) typeValue.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.