Package com.typesafe.config

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


        try {
            size = getLong(path);
        } catch (ConfigException.WrongType e) {
            ConfigValue v = find(path, ConfigValueType.STRING);
            size = parseBytes((String) v.unwrapped(),
                    v.origin(), path);
        }
        return size;
    }

    @Deprecated
View Full Code Here


    @Override
    public long getDuration(String path, TimeUnit unit) {
        ConfigValue v = find(path, ConfigValueType.STRING);
        long result = unit.convert(
                       parseDuration((String) v.unwrapped(), v.origin(), path),
                       TimeUnit.NANOSECONDS);
        return result;
    }

    @SuppressWarnings("unchecked")
View Full Code Here

                                }
                            }
                            ((ValueCodable) objectShell).fromConfigValue(configValue, mergedDefaults);
                            return objectShell;
                        } catch (InstantiationException | IllegalAccessException | RuntimeException ex) {
                            throw new ConfigException.BadValue(configValue.origin(), singleKeyType.getName(),
                                                               "exception during instantiation of a ValueCodable", ex);
                        }
                    } else {
                        throw new ConfigException.WrongType(configValue.origin(), singleKeyName,
                                                            "OBJECT", configValue.valueType().toString());
View Full Code Here

                        } catch (InstantiationException | IllegalAccessException | RuntimeException ex) {
                            throw new ConfigException.BadValue(configValue.origin(), singleKeyType.getName(),
                                                               "exception during instantiation of a ValueCodable", ex);
                        }
                    } else {
                        throw new ConfigException.WrongType(configValue.origin(), singleKeyName,
                                                            "OBJECT", configValue.valueType().toString());
                    }
                }
                ConfigObject fieldValues = ((ConfigObject) configValue).withFallback(aliasDefaults);
                return createAndPopulate(singleKeyInfo, singleKeyType, fieldValues);
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 {
                Class<T> normalType = (Class<T>) pluginMap.getClass(stype);
View Full Code Here

            String fieldName = fieldInfo.getName();
            ConfigValue fieldValue = root.get(fieldName);
            if ((fieldValue == null) && (fieldDefaults.get(fieldName) != null)) {
                ConfigValue fieldDefault = fieldDefaults.get(fieldName);
                fieldValue = ConfigValueFactory.fromAnyRef(
                        fieldDefault.unwrapped(), "global default : " + fieldDefault.origin().description());
                root = root.withValue(fieldName, fieldValue);
            }
            if (fieldValue == null) {
                continue;
            }
View Full Code Here

                    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());
                        }
                    }
                    ConfigObject fieldValues = (ConfigObject) onlyKeyValue;
                    return fieldValues.withValue(classField, ConfigValueFactory.fromAnyRef(
View Full Code Here

            if (defaultObject != null) {
                String defaultName = pluginMap.getLastAlias("_default");
                ConfigObject aliasDefaults = pluginMap.aliasDefaults("_default");
                return root.withValue(classField, ConfigValueFactory.fromAnyRef(
                        defaultName, pluginMap.category() + " default type : "
                                     + defaultObject.origin().description()))
                           .withFallback(aliasDefaults);
            }
        }
        return root;
    }
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 {
                Class<T> normalType = (Class<T>) pluginMap.getClass(stype);
View Full Code Here

                                    }
                                }
                                ((ValueCodable) objectShell).fromConfigValue(configValue, mergedDefaults);
                                return objectShell;
                            } catch (InstantiationException | IllegalAccessException | RuntimeException ex) {
                                throw new ConfigException.BadValue(configValue.origin(), singleKeyType.getName(),
                                                                   "exception during instantiation of a ValueCodable", ex);
                            }
                        } else {
                            throw new ConfigException.WrongType(configValue.origin(), singleKeyName,
                                                                "OBJECT", configValue.valueType().toString());
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.