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


Java ConfigObject類代碼示例

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


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

示例1: loadQueryPlanPatterns

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private Map<Language, List<QueryPlanPatterns>> loadQueryPlanPatterns(Config config) {
    Map<Language, List<QueryPlanPatterns>> rulesByLang = new LinkedHashMap<>();
    ConfigObject configObject = config.getObject("rules.planner-pattern");

    configObject.keySet().forEach(strLang -> {
        Language language = Language.valueOf(strLang.toUpperCase());
        List<QueryPlanPatterns> plans = new ArrayList<>();

        List<? extends ConfigObject> innerCfg = configObject.toConfig().getObjectList(strLang);
        innerCfg.forEach(e -> {
            Map<String, Object> plan = e.unwrapped();
            String planId = plan.keySet().toArray(new String[1])[0];
            List<String> triplePatterns = (List<String>)plan.values().toArray()[0];
            plans.add(new QueryPlanPatterns(planId,
                    triplePatterns.stream().map(TriplePattern::new).collect(Collectors.toList())));
        });

        rulesByLang.put(language, plans);
    });

    return rulesByLang;
}
 
開發者ID:Lambda-3,項目名稱:Stargraph,代碼行數:24,代碼來源:Rules.java

示例2: loadStopPatterns

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
private Map<Language, List<Pattern>> loadStopPatterns(Config config) {
    Map<Language, List<Pattern>> rulesByLang = new LinkedHashMap<>();
    ConfigObject configObject = config.getObject("rules.stop-pattern");

    configObject.keySet().forEach(strLang -> {
        Language language = Language.valueOf(strLang.toUpperCase());
        List<String> patternStr = configObject.toConfig().getStringList(strLang);

        rulesByLang.compute(language,
                (lang, pattern) -> patternStr.stream().map(Pattern::compile).collect(Collectors.toList()));

        logger.info(marker, "Loaded {} Stop patterns for '{}'", rulesByLang.get(language).size(), language);

    });

    return rulesByLang;
}
 
開發者ID:Lambda-3,項目名稱:Stargraph,代碼行數:18,代碼來源:Rules.java

示例3: dispatchConfig

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
private void dispatchConfig(Config config, ConfigCallback callback) {
    for (Map.Entry<String, ConfigValue> entry : config.root().entrySet()) {
        final String id = entry.getKey();

        try {
            final Config entryConfig = ((ConfigObject) entry.getValue()).toConfig();
            final String type = entryConfig.getString("type");

            if (Strings.isNullOrEmpty(type)) {
                errors.add(new ConfigurationError("Missing type field for " + id + " (" + entryConfig + ")"));
                continue;
            }

            callback.call(type, id, entryConfig);
        } catch (ConfigException e) {
            errors.add(new ConfigurationError("[" + id + "] " + e.getMessage()));
        }
    }
}
 
開發者ID:DevOpsStudio,項目名稱:Re-Collector,代碼行數:20,代碼來源:ConfigurationRegistry.java

示例4: peerTrusted

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
@ValidateMe
public NodeFilter peerTrusted() {
    List<? extends ConfigObject> list = config.getObjectList("peer.trusted");
    NodeFilter ret = new NodeFilter();

    for (ConfigObject configObject : list) {
        byte[] nodeId = null;
        String ipMask = null;
        if (configObject.get("nodeId") != null) {
            nodeId = Hex.decode(configObject.toConfig().getString("nodeId").trim());
        }
        if (configObject.get("ip") != null) {
            ipMask = configObject.toConfig().getString("ip").trim();
        }
        ret.add(nodeId, ipMask);
    }
    return ret;
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:19,代碼來源:SystemProperties.java

示例5: walletAccounts

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
public List<WalletAccount> walletAccounts() {
    if (!configFromFiles.hasPath("wallet.accounts")) {
        return Collections.emptyList();
    }

    List<WalletAccount> ret = new ArrayList<>();
    List<? extends ConfigObject> list = configFromFiles.getObjectList("wallet.accounts");

    for (ConfigObject configObject : list) {
        WalletAccount acc = null;
        if (configObject.get("privateKey") != null) {
            acc = new WalletAccount(configObject.toConfig().getString("privateKey"));
        }

        if (acc != null) {
            ret.add(acc);
        }
    }

    return ret;
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:22,代碼來源:RskSystemProperties.java

示例6: getParameters

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
private static Map<Integer, Integer> getParameters(List<? extends ConfigObject> params)
{
	Map<Integer, Integer> result = new HashMap<Integer, Integer>();

	for(ConfigObject cfgObj : params)
	{
		if (cfgObj.containsKey("profiles") && cfgObj.containsKey("value"))
		{
			String[] profiles = cfgObj.toConfig().getString("profiles").split(",");
			for (String profileStr : profiles)
			{
				profileStr = profileStr.trim();
				Integer profile = ("any".equalsIgnoreCase(profileStr)) ? -1 : RoutingProfileType.getFromString(profileStr);
				if (profile != RoutingProfileType.UNKNOWN)
					result.put(profile, cfgObj.toConfig().getInt("value"));
			}
		}
	}

	return result;
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:22,代碼來源:AccessibilityServiceSettings.java

示例7: readModuleShardsConfig

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
private static Map<String, ModuleConfig.Builder> readModuleShardsConfig(final Config moduleShardsConfig) {
    final List<? extends ConfigObject> moduleShardsConfigObjectList =
        moduleShardsConfig.getObjectList("module-shards");

    final Map<String, ModuleConfig.Builder> moduleConfigMap = new HashMap<>();
    for (final ConfigObject moduleShardConfigObject : moduleShardsConfigObjectList) {
        final String moduleName = moduleShardConfigObject.get("name").unwrapped().toString();
        final ModuleConfig.Builder builder = ModuleConfig.builder(moduleName);

        final List<? extends ConfigObject> shardsConfigObjectList =
            moduleShardConfigObject.toConfig().getObjectList("shards");

        for (final ConfigObject shard : shardsConfigObjectList) {
            final String shardName = shard.get("name").unwrapped().toString();
            final List<MemberName> replicas = shard.toConfig().getStringList("replicas").stream()
                    .map(MemberName::forName).collect(Collectors.toList());
            builder.shardConfig(shardName, replicas);
        }

        moduleConfigMap.put(moduleName, builder);
    }

    return moduleConfigMap;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:25,代碼來源:FileModuleShardConfigProvider.java

示例8: testNestedObject

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
@Test
public void testNestedObject() throws Exception {
    final String JSON = "{\"array\":[1,2],\"obj\":{\"first\":true}}";
    ConfigObject value = MAPPER.readValue(JSON, ConfigObject.class);
    assertEquals(ConfigValueType.OBJECT, value.valueType());
    assertEquals(2, value.size());

    ConfigList array = (ConfigList) value.get("array");
    assertEquals(ConfigValueType.LIST, array.valueType());
    assertEquals(2, (array.unwrapped().size()));

    ConfigValue objValue = value.get("obj");
    assertEquals(ConfigValueType.OBJECT, objValue.valueType());
    ConfigObject obj = (ConfigObject) objValue;
    assertEquals(1, (obj.size()));
}
 
開發者ID:DigitalAssetCom,項目名稱:-deprecated-hlp-candidate,代碼行數:17,代碼來源:HoconDeserializerTest.java

示例9: BatchStep

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
public BatchStep(String name, Config config) {
  super(name, config);
  
  if ((config.hasPath(INPUT_PREFIX + REPARTITION_NUM_PARTITIONS_PROPERTY) ||
       config.hasPath(DERIVER_PREFIX + REPARTITION_NUM_PARTITIONS_PROPERTY) ||
       config.hasPath(INPUT_PREFIX + REPARTITION_COLUMNS_PROPERTY) ||
       config.hasPath(DERIVER_PREFIX + REPARTITION_COLUMNS_PROPERTY)) &&
      (config.hasPath(INPUT_PREFIX + COALESCE_NUM_PARTITIONS_PROPERTY) ||
       config.hasPath(DERIVER_PREFIX + COALESCE_NUM_PARTITIONS_PROPERTY)))
  {
    throw new RuntimeException("Step " + getName() + " can not both repartition and coalesce.");
  }

  if (config.hasPath(REPETITION_PREFIX)) {
    ConfigObject repConfig = config.getObject(REPETITION_PREFIX);
    for (String rep : repConfig.keySet()) {
      RepetitionFactory.create(this, rep, config.getConfig(REPETITION_PREFIX).getConfig(rep));
    }
  }
}
 
開發者ID:cloudera-labs,項目名稱:envelope,代碼行數:21,代碼來源:BatchStep.java

示例10: readConfigValue

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
private void readConfigValue(ConfigValue value, CommentedConfigurationNode node) {
    if (!value.origin().comments().isEmpty()) {
        node.setComment(CRLF_MATCH.matcher(Joiner.on('\n').join(value.origin().comments())).replaceAll(""));
    }
    switch (value.valueType()) {
        case OBJECT:
            if (((ConfigObject) value).isEmpty()) {
                node.setValue(ImmutableMap.of());
            } else {
                for (Map.Entry<String, ConfigValue> ent : ((ConfigObject) value).entrySet()) {
                    readConfigValue(ent.getValue(), node.getNode(ent.getKey()));
                }
            }
            break;
        case LIST:
            List<ConfigValue> values = (ConfigList) value;
            for (int i = 0; i < values.size(); ++i) {
                readConfigValue(values.get(i), node.getNode(i));
            }
            break;
        case NULL:
            return;
        default:
            node.setValue(value.unwrapped());
    }
}
 
開發者ID:SpongePowered,項目名稱:configurate,代碼行數:27,代碼來源:HoconConfigurationLoader.java

示例11: setUp

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
@Before
public void setUp() {
  initMocks(this);
  fixture = new LoadElasticsearchBuilder();
  
  when(esConfig.getStringList(DocumentLoaderFactory.HOSTS_FIELD)).thenReturn(Arrays.asList("test123"));
  when(esConfig.getString(DocumentLoaderFactory.CLUSTER_NAME_FIELD)).thenReturn("test");
  when(config.getConfig(LoadElasticsearchBuilder.ELASTICSEARCH_CONFIGURATION)).thenReturn(esConfig);
  when(config.getString(LoadElasticsearchBuilder.DOCUMENT_LOADER_TYPE))
          .thenReturn(DocumentLoaderFactory.TRANSPORT_DOCUMENT_LOADER);
  when(config.getString(LoadElasticsearchBuilder.INDEX_NAME)).thenReturn("foo");
  when(config.getString(LoadElasticsearchBuilder.TYPE)).thenReturn("bar");
  ConfigObject obj = mock(ConfigObject.class);
  when(obj.keySet()).thenReturn(new HashSet<String>());
  when(config.root()).thenReturn(obj);
}
 
開發者ID:sematext,項目名稱:kite-morphlines-elasticsearch,代碼行數:17,代碼來源:LoadElasticsearchBuilderTest.java

示例12: loadServerListFromConf

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
public <T> ArrayList<InetSocketAddress> loadServerListFromConf(Class<T> clazz){
	ArrayList<InetSocketAddress> serverList = new ArrayList<InetSocketAddress>();
	List<? extends ConfigObject> objConfList = getConfig().getObjectList("client.objects");
	for(ConfigObject conf : objConfList){
		Object name = conf.get("name").unwrapped();
		if(name.equals(clazz.getName())){
			String[] servers = ((String)conf.get("servers").unwrapped()).split(" ");
			for(int i=0;i<servers.length;i++){
				String[] ipAndPort = servers[i].split(":");
				serverList.add(new InetSocketAddress(ipAndPort[0],Integer.parseInt(ipAndPort[1])));
			}
		}
	}
	
	if(serverList.isEmpty()){
		throw new RuntimeException("server list is empty, can not find any corresponding client.objects in the conf file.");
	}
	return serverList;
}
 
開發者ID:dawnbreaks,項目名稱:NettyRPC,代碼行數:20,代碼來源:RPCClient.java

示例13: initConfig

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
private void initConfig(Config config) {
	List<? extends ConfigObject> nodes=config.getObjectList("server.hosts");
   	for (ConfigObject node : nodes) {
   		  Integer remotePort=Integer.parseInt(node.get("remotePort").render());
  		      String remoteIp=node.get("remoteHost").unwrapped().toString();//遠程主機的ip
  		      String name=node.containsKey("name")?node.get("name").unwrapped().toString():remoteIp;//主機別名
  		      InetSocketAddress host=new InetSocketAddress(remoteIp, remotePort);
  		      address.add(host);
   	      alias.put(name, host);
   	      //TODO 獲取
   	      for(ServiceType serviceType : ServiceConfig.ServiceType.values()){
   	    	   String serviceName=serviceType.name().toLowerCase();
   	    	  if(node.containsKey(serviceName)){
   	    		  HashMap fcs=(HashMap) node.get(serviceName).unwrapped();
   	    		  ServiceConfig serviceConfig=new ServiceConfig();
   	    		  serviceConfig.setServiceType(serviceType);
   	    		  serviceConfig.setInfo(fcs);
   	    		  services.add(serviceConfig);
   	    	  }
   	      }
   	     
   	}
   	String chost=config.getString("client.currentHost");
	int port=config.getInt("client.currentPort");
	currentHost=new InetSocketAddress(chost, port);
}
 
開發者ID:desperado1992,項目名稱:distributeTemplate,代碼行數:27,代碼來源:ConfigBuilder.java

示例14: propertySet

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void propertySet() throws Exception {
  Set<Entry<String, Object>> entries = new HashSet<>();
  new MockUnit(Config.class)
      .expect(unit -> {
        Config config = unit.get(Config.class);
        ConfigObject root = unit.mock(ConfigObject.class);
        Map<String, Object> unwrapped = unit.mock(Map.class);
        expect(config.root()).andReturn(root);
        expect(root.unwrapped()).andReturn(unwrapped);
        expect(unwrapped.entrySet()).andReturn(entries);
      })
      .run(unit -> {
        assertEquals(entries,
            new ConfigValueResolver().propertySet(unit.get(Config.class)));
      });
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:19,代碼來源:ConfigValueResolverTest.java

示例15: wrap

import com.typesafe.config.ConfigObject; //導入依賴的package包/類
@Override
public TemplateModel wrap(final Object obj) throws TemplateModelException {
  if (obj instanceof Config) {
    ConfigObject config = ((Config) obj).root();
    return DefaultMapAdapter.adapt(config.unwrapped(), (ObjectWrapperWithAPISupport) wrapper);
  }
  if (obj instanceof Request) {
    Map<String, Object> req = ((Request) obj).attributes();
    return DefaultMapAdapter.adapt(req, (ObjectWrapperWithAPISupport) wrapper);
  }
  if (obj instanceof Session) {
    Session session = (Session) obj;
    if (session.isDestroyed()) {
      return wrapper.wrap(null);
    }
    Map<String, String> hash = session.attributes();
    return DefaultMapAdapter.adapt(hash, (ObjectWrapperWithAPISupport) wrapper);
  }
  return wrapper.wrap(obj);
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:21,代碼來源:FtlWrapper.java


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