本文整理汇总了Java中com.typesafe.config.ConfigValueType.equals方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigValueType.equals方法的具体用法?Java ConfigValueType.equals怎么用?Java ConfigValueType.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.typesafe.config.ConfigValueType
的用法示例。
在下文中一共展示了ConfigValueType.equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeUDFs
import com.typesafe.config.ConfigValueType; //导入方法依赖的package包/类
private static void initializeUDFs(Config config) {
if (!config.hasPath("udfs")) return;
if (!config.getValue("udfs").valueType().equals(ConfigValueType.LIST)) {
throw new RuntimeException("UDFs must be provided as a list");
}
ConfigList udfList = config.getList("udfs");
for (ConfigValue udfValue : udfList) {
ConfigValueType udfValueType = udfValue.valueType();
if (!udfValueType.equals(ConfigValueType.OBJECT)) {
throw new RuntimeException("UDF list must contain UDF objects");
}
Config udfConfig = ((ConfigObject)udfValue).toConfig();
for (String path : Lists.newArrayList("name", "class")) {
if (!udfConfig.hasPath(path)) {
throw new RuntimeException("UDF entries must provide '" + path + "'");
}
}
String name = udfConfig.getString("name");
String className = udfConfig.getString("class");
// null third argument means that registerJava will infer the return type
Contexts.getSparkSession().udf().registerJava(name, className, null);
LOG.info("Registered Spark SQL UDF: " + name);
}
}
示例2: getConfigValue
import com.typesafe.config.ConfigValueType; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private Object getConfigValue(Class<?> paramClass, Type paramType, String path) {
Optional<Object> extractedValue = ConfigExtractors.extractConfigValue(config, paramClass, path);
if (extractedValue.isPresent()) {
return extractedValue.get();
}
ConfigValue configValue = config.getValue(path);
ConfigValueType valueType = configValue.valueType();
if (valueType.equals(ConfigValueType.OBJECT) && Map.class.isAssignableFrom(paramClass)) {
ConfigObject object = config.getObject(path);
return object.unwrapped();
} else if (valueType.equals(ConfigValueType.OBJECT)) {
Object bean = ConfigBeanFactory.create(config.getConfig(path), paramClass);
return bean;
} else if (valueType.equals(ConfigValueType.LIST) && List.class.isAssignableFrom(paramClass)) {
Type listType = ((ParameterizedType) paramType).getActualTypeArguments()[0];
Optional<List<?>> extractedListValue =
ListExtractors.extractConfigListValue(config, listType, path);
if (extractedListValue.isPresent()) {
return extractedListValue.get();
} else {
List<? extends Config> configList = config.getConfigList(path);
return configList.stream()
.map(cfg -> {
Object created = ConfigBeanFactory.create(cfg, (Class) listType);
return created;
})
.collect(Collectors.toList());
}
}
throw new RuntimeException("Cannot obtain config value for " + paramType + " at path: " + path);
}
示例3: checkType
import com.typesafe.config.ConfigValueType; //导入方法依赖的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);
}
}