本文整理汇总了Java中com.typesafe.config.ConfigValue.origin方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigValue.origin方法的具体用法?Java ConfigValue.origin怎么用?Java ConfigValue.origin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.typesafe.config.ConfigValue
的用法示例。
在下文中一共展示了ConfigValue.origin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invalidValue
import com.typesafe.config.ConfigValue; //导入方法依赖的package包/类
private SwiftConfigException invalidValue(ConfigValue value, String k, Object v, ConfigPropertyType<?> t) {
switch (t.toString().charAt(0)) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
return new SwiftConfigException(value.origin(), "invalid value '" + v + "' for property '" + k + "'. Expected an " + t);
default:
return new SwiftConfigException(value.origin(), "invalid value '" + v + "' for property '" + k + "'. Expected a " + t);
}
}
示例2: getTokenLocation
import com.typesafe.config.ConfigValue; //导入方法依赖的package包/类
@Override
public JsonLocation getTokenLocation() {
ConfigValue current = currentConfig();
if (current == null) {
return JsonLocation.NA;
}
ConfigOrigin nodeOrigin = current.origin();
return new JsonLocation(current, -1, nodeOrigin.lineNumber(), -1);
}
示例3: checkType
import com.typesafe.config.ConfigValue; //导入方法依赖的package包/类
private void checkType(String name, ConfigValue value, ConfigValueType type) {
if (!type.equals(value.valueType())) {
throw new SwiftConfigException(value.origin(),
"'" + name + "': wrong type (" + value.valueType() + "). Must be a " + type);
}
}
示例4: fromConfigValue
import com.typesafe.config.ConfigValue; //导入方法依赖的package包/类
public static JsonLocation fromConfigValue(ConfigValue configValue) {
ConfigOrigin configOrigin = configValue.origin();
return new JsonLocation(configValue, -1, configOrigin.lineNumber(), -1);
}
示例5: PluginMap
import com.typesafe.config.ConfigValue; //导入方法依赖的package包/类
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);
}
示例6: getTokenLocation
import com.typesafe.config.ConfigValue; //导入方法依赖的package包/类
@Override
public JsonLocation getTokenLocation() {
final ConfigValue node = currentNode();
return node == null ? JsonLocation.NA : new HoconJsonLocation(node.origin());
}
示例7: getCurrentLocation
import com.typesafe.config.ConfigValue; //导入方法依赖的package包/类
@Override
public JsonLocation getCurrentLocation() {
final ConfigValue node = currentNode();
return node == null ? JsonLocation.NA : new HoconJsonLocation(node.origin());
}