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


Java ConfigValueType.NULL属性代码示例

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


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

示例1: KeyValue

KeyValue(Map.Entry<String, ConfigValue> keyValue) {
  key = keyValue.getKey();
  description = createDescription(keyValue.getValue());
  try {
    if (keyValue.getValue().valueType() == ConfigValueType.NULL) {
      valueType = "N/A (null)";
      defaultValue = "null";
    } else {
      valueType = keyValue.getValue().valueType().name().toLowerCase();
      defaultValue = render(keyValue.getValue());
    }
  } catch (ConfigException.NotResolved e) {
    valueType = "N/A (unresolved)";
    defaultValue = keyValue.getValue().render();
  }
}
 
开发者ID:okvee,项目名称:tscfg-docgen,代码行数:16,代码来源:Configuration.java

示例2: nullValues

private static Set<Map.Entry<String, ConfigValue>> nullValues(ConfigObject config) {
  Set<Map.Entry<String, ConfigValue>> result = new HashSet<>();
  for (Map.Entry<String, ConfigValue> entry : config.entrySet()) {
    try {
      if (entry.getValue().valueType() == ConfigValueType.NULL) {
        result.add(entry);
      } else if (entry.getValue().valueType() == ConfigValueType.OBJECT) {
        result.addAll(nullValues((ConfigObject) entry.getValue()));
      }
    } catch (ConfigException.NotResolved e) {
      // unresolved substitutions are handled elsewhere, here we just ignore them
    }
  }
  return result;
}
 
开发者ID:okvee,项目名称:tscfg-docgen,代码行数:15,代码来源:Configuration.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.NULL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。