當前位置: 首頁>>代碼示例>>Java>>正文


Java ConfigValue.unwrapped方法代碼示例

本文整理匯總了Java中com.typesafe.config.ConfigValue.unwrapped方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigValue.unwrapped方法的具體用法?Java ConfigValue.unwrapped怎麽用?Java ConfigValue.unwrapped使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.typesafe.config.ConfigValue的用法示例。


在下文中一共展示了ConfigValue.unwrapped方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: CustomTagMappings

import com.typesafe.config.ConfigValue; //導入方法依賴的package包/類
/**
 * Creates a new custom tag mappings object from the given configuration. The keys of the
 * configuration are well-known tag names, and the values are the custom tag names.
 *
 * @param config config holding custom tags
 * @throws IllegalArgumentException if any configuration value is not a string or is empty
 */
public CustomTagMappings(Config config) {
  ImmutableMap.Builder<String, String> b = ImmutableMap.builder();

  if (config != null) {
    for (Map.Entry<String,ConfigValue> e : config.entrySet()) {
      String key = e.getKey();
      ConfigValue value = e.getValue();
      switch (value.valueType()) {
        case STRING:
          String customTagName = (String) value.unwrapped();
          if (customTagName.isEmpty()) {
            throw new IllegalArgumentException("Tag mapping " + key + " is empty");
          }
          b.put(key, customTagName);
          break;
        default:
          throw new IllegalArgumentException("Tag mapping " + key + " is not a string: " + value);
      }
    }
  }

  customTagNames = b.build();
}
 
開發者ID:cloudera,項目名稱:director-aws-plugin,代碼行數:31,代碼來源:CustomTagMappings.java

示例2: checkValue

import com.typesafe.config.ConfigValue; //導入方法依賴的package包/類
private Object checkValue(String k, ConfigValue value, ConfigPropertyType<?> t) {
    Object v = value.unwrapped();
    switch (value.valueType()) {
        case STRING:
            // allow auto-conversion from string
            return t.check(k, value.unwrapped(), value.origin());
        case NUMBER:
            if (t.getBaseType() != ConfigPropertyType.INT && t.getBaseType() != ConfigPropertyType.FLOAT) {
                throw invalidValue(value, k, v, t.getBaseType());
            }
            if (t.getBaseType() == ConfigPropertyType.INT) {
                Number n = (Number) value.unwrapped();
                if (n.intValue() != n.doubleValue()) {
                    throw invalidValue(value, k, v, t.getBaseType());
                }
            }
            return t.check(k, v, null);
        case BOOLEAN:
            if (t.getBaseType() != ConfigPropertyType.BOOLEAN) {
                throw invalidValue(value, k, v, t.getBaseType());
            }
            return value.unwrapped();
        default:
            return t.check(k, v, value.origin());
    }
}
 
開發者ID:swift-lang,項目名稱:swift-k,代碼行數:27,代碼來源:SwiftConfigSchema.java

示例3: currentNumericNode

import com.typesafe.config.ConfigValue; //導入方法依賴的package包/類
protected JsonNode currentNumericNode() throws JsonParseException {
    ConfigValue configValue = currentNode();
    if ((configValue == null) || (configValue.valueType() != ConfigValueType.NUMBER)) {
        JsonToken t = (configValue == null) ? null : ConfigNodeCursor.forConfigValue(configValue);
        throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors");
    }
    Number value = (Number) configValue.unwrapped();
    if (value instanceof Double) {
        return JsonNodeFactory.instance.numberNode((Double) value);
    }
    if (value instanceof Long) {
        return JsonNodeFactory.instance.numberNode((Long) value);
    }
    if (value instanceof Integer) {
        return JsonNodeFactory.instance.numberNode((Integer) value);
    }
    // only possible if Config has since added more numeric types
    throw _constructError(value.getClass() + " is not a supported numeric config type");
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:20,代碼來源:ConfigTraversingParser.java

示例4: getVariables

import com.typesafe.config.ConfigValue; //導入方法依賴的package包/類
public List<Variable> getVariables() {
    List<Variable> variables = new ArrayList<>();
    File file = new File(jythonPath);

    String[] packages = file.list();

    if (packages == null) {
        // No workflow packages deployed, return empty list
        return variables;
    }

    for (String packageName : packages) {
        File packageDir = new File(file.getAbsolutePath() + File.separator + packageName);

        if (packageDir.isDirectory()) {
            File workflowsDir = new File(packageDir.getAbsolutePath() + File.separator + "workflows");
            File confFile = new File(workflowsDir.getAbsolutePath() + File.separator + "workflows.conf");

            if (confFile.exists()) {
                Config config = ConfigFactory.parseFile(confFile);

                if (config.hasPath("variables")) {
                    for (ConfigValue value : config.getObject("variables").values()) {
                        Map map = (Map) value.unwrapped();
                        variables.add(new Variable(map.get("name").toString(), map.get("description").toString(),
                              map.get("actor").toString(), map.get("parameter").toString(), map.get("type").toString()));
                    }
                }

            }
        }
    }

    return variables;
}
 
開發者ID:kurator-org,項目名稱:kurator-web,代碼行數:36,代碼來源:ConfigManager.java

示例5: processActorDefinition

import com.typesafe.config.ConfigValue; //導入方法依賴的package包/類
Optional<RouteHandlerBuilder> processActorDefinition(ConfigValue cvalue) {
    
    try {
        // extract actor definition
        Map<String, Object> map = (Map<String, Object>) cvalue.unwrapped();

        String actorRef   = (String) map.get("ref");
        String methodName = (String) map.get("call");
        String actorClass = (String) map.get("class");
        
        Optional<ActorRef> ref = Optional.empty();
        
        if (!StringUtils.isEmpty(actorRef)) {
            // get actor by reference supplied
            ref = factory.getLocalActorByRef(actorRef);
        }
        
        if (!StringUtils.isEmpty(actorClass)) {
            // create new actor using class specified
            ref = factory.getLocalActor(actorClass);
            
        }

        return Optional.ofNullable(
                RouteHandler.builder()
                            .withActorRef(ref)
                            .withMethodName(methodName)
        );
    }
    catch (Exception ex) {
        log.warn("Error parsing actor definition: "+cvalue.render());
    }
    
    return empty();
}
 
開發者ID:gibffe,項目名稱:fuse,代碼行數:36,代碼來源:RoutesConfigImpl.java

示例6: forConfigValue

import com.typesafe.config.ConfigValue; //導入方法依賴的package包/類
static JsonToken forConfigValue(ConfigValue configValue) {
    ConfigValueType valueType = configValue.valueType();
    switch (valueType) {
        case NUMBER:
            if (configValue.unwrapped() instanceof Double) {
                return JsonToken.VALUE_NUMBER_FLOAT;
            } else {
                return JsonToken.VALUE_NUMBER_INT;
            }
        case BOOLEAN:
            if (configValue.unwrapped().equals(Boolean.TRUE)) {
                return JsonToken.VALUE_TRUE;
            } else {
                return JsonToken.VALUE_FALSE;
            }
        case NULL:
            return JsonToken.VALUE_NULL;
        case STRING:
            return JsonToken.VALUE_STRING;
        case OBJECT:
            return JsonToken.START_OBJECT;
        case LIST:
            return JsonToken.START_ARRAY;
        default:
            // not possible unless the set of enums changes on us later
            throw new IllegalArgumentException(valueType.name() + " is not a supported ConfigValueType");
    }
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:29,代碼來源:ConfigNodeCursor.java

示例7: getNumberType

import com.typesafe.config.ConfigValue; //導入方法依賴的package包/類
@Override
public NumberType getNumberType() throws IOException, JsonParseException {
	ConfigValue n = currentNumericNode();
	if(n == null)
		return null;
	
	Number value = (Number) n.unwrapped();
	if(value instanceof Double) {
		return NumberType.DOUBLE;
	} else if(value instanceof Long) {
		return NumberType.LONG;
	} else {
		return NumberType.INT;
	}
}
 
開發者ID:jclawson,項目名稱:jackson-dataformat-hocon,代碼行數:16,代碼來源:HoconTreeTraversingParser.java

示例8: getServiceParametersMap

import com.typesafe.config.ConfigValue; //導入方法依賴的package包/類
public Map<String,Object> getServiceParametersMap(String serviceName, String paramName, boolean quotedStrings)
{
	Map<String,Object> result = null;
	
	try
	{
		String rootPath = "ors.services." + serviceName + "." + paramName;
		ConfigObject configObj = _config.getObject(rootPath);
		
		result = new HashMap<String, Object>();
		
		for(String key : configObj.keySet())
		{
			Object value = null;
			ConfigValue paramValue = _config.getValue(rootPath + "." + key);

			switch(paramValue.valueType())
			{
			case NUMBER:
				value = paramValue.unwrapped();
				break;
			case OBJECT:
				Map<String,Object> map = getServiceParametersMap(serviceName, paramName + "." + key, quotedStrings);
				value = map;
				break;
			case LIST:
				value = paramValue.unwrapped();
				break;
			case STRING:
				if (quotedStrings)
					value = paramValue.render();
				else
					value = StringUtility.trim(paramValue.render(), '"');
				break;
			case BOOLEAN:
				value = paramValue.unwrapped();
			default:
				break;
			}
			
			result.put(key, value);
		}
	}
	catch(Exception ex)
	{}
	
	return result;
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:49,代碼來源:AppConfig.java

示例9: 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);
}
 
開發者ID:addthis,項目名稱:codec,代碼行數:65,代碼來源:PluginMap.java


注:本文中的com.typesafe.config.ConfigValue.unwrapped方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。