当前位置: 首页>>代码示例>>Java>>正文


Java ConfigValueType.STRING属性代码示例

本文整理汇总了Java中com.typesafe.config.ConfigValueType.STRING属性的典型用法代码示例。如果您正苦于以下问题:Java ConfigValueType.STRING属性的具体用法?Java ConfigValueType.STRING怎么用?Java ConfigValueType.STRING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.typesafe.config.ConfigValueType的用法示例。


在下文中一共展示了ConfigValueType.STRING属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValueTypeOrNull

private static ConfigValueType getValueTypeOrNull(Class<?> parameterClass) {
    if (parameterClass == Boolean.class || parameterClass == boolean.class) {
        return ConfigValueType.BOOLEAN;
    } else if (parameterClass == Integer.class || parameterClass == int.class) {
        return ConfigValueType.NUMBER;
    } else if (parameterClass == Double.class || parameterClass == double.class) {
        return ConfigValueType.NUMBER;
    } else if (parameterClass == Long.class || parameterClass == long.class) {
        return ConfigValueType.NUMBER;
    } else if (parameterClass == String.class) {
        return ConfigValueType.STRING;
    } else if (parameterClass == Duration.class) {
        return null;
    } else if (parameterClass == ConfigMemorySize.class) {
        return null;
    } else if (parameterClass == List.class) {
        return ConfigValueType.LIST;
    } else if (parameterClass == Map.class) {
        return ConfigValueType.OBJECT;
    } else if (parameterClass == Config.class) {
        return ConfigValueType.OBJECT;
    } else if (parameterClass == ConfigObject.class) {
        return ConfigValueType.OBJECT;
    } else if (parameterClass == ConfigList.class) {
        return ConfigValueType.LIST;
    } else {
        return null;
    }
}
 
开发者ID:mpusher,项目名称:mpush,代码行数:29,代码来源:ConfigBeanImpl.java

示例2: getPassThruCost

public static int getPassThruCost(Config config, String key) {
	ConfigValue val = config.getValue(key);
	return val.valueType() == ConfigValueType.STRING ? -1 : ((Number)val.unwrapped()).intValue();
}
 
开发者ID:unascribed,项目名称:Farrago,代码行数:4,代码来源:FarragoMod.java

示例3: PluginMap

public PluginMap(@Nonnull String category, @Nonnull Config config) {
    this.config = config;
    this.category = checkNotNull(category);
    classField = config.getString("_field");
    boolean errorMissing = config.getBoolean("_strict");
    if (config.hasPath("_class")) {
        String baseClassName = config.getString("_class");
        try {
            baseClass = Class.forName(baseClassName);
        } catch (ClassNotFoundException e) {
            log.error("could not find specified base class {} for category {}",
                      baseClassName, category);
            throw new RuntimeException(e);
        }
    } else {
        baseClass = null;
    }
    Set<String> labels = config.root().keySet();
    BiMap<String, Class<?>> mutableMap = HashBiMap.create(labels.size());
    Map<String, String> mutableAliasMap = new HashMap<>();
    Set<String> mutableInlinedAliasSet = new HashSet<>();
    for (String label : labels) {
        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") &&
                    configObject.toConfig().getBoolean("_inline")) {
                mutableInlinedAliasSet.add(label);
            }
        } else if (configValue.valueType() == ConfigValueType.NULL) {
            continue;
        } 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 {
            try {
                Class<?> foundClass = findAndValidateClass(className);
                mutableMap.put(label, foundClass);
            } catch (ClassNotFoundException maybeSwallowed) {
                if (errorMissing) {
                    throw new RuntimeException(maybeSwallowed);
                } else {
                    log.warn("plugin category {} with alias {} is pointing to missing class {}",
                             category, label, className);
                }
            }
        }
    }
    map = Maps.unmodifiableBiMap(mutableMap);
    aliases = Collections.unmodifiableMap(mutableAliasMap);
    checkAliasesForCycles();
    inlinedAliases = Collections.unmodifiableSet(mutableInlinedAliasSet);
}
 
开发者ID:addthis,项目名称:codec,代码行数:64,代码来源:PluginMap.java


注:本文中的com.typesafe.config.ConfigValueType.STRING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。