Java 类com.typesafe.config.ConfigObject 实例源码

项目:Stargraph    文件:Rules.java   
@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;
}
项目:Stargraph    文件:Rules.java   
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;
}
项目:Re-Collector    文件:ConfigurationRegistry.java   
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()));
        }
    }
}
项目:talchain    文件:SystemProperties.java   
@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;
}
项目:rskj    文件:RskSystemProperties.java   
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;
}
项目:AppCoins-ethereumj    文件:SystemProperties.java   
@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;
}
项目:openrouteservice    文件:AccessibilityServiceSettings.java   
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;
}
项目:openrouteservice    文件:IsochronesServiceSettings.java   
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;
}
项目:hashsdn-controller    文件:FileModuleShardConfigProvider.java   
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;
}
项目:-deprecated-hlp-candidate    文件:HoconDeserializerTest.java   
@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()));
}
项目:envelope    文件:BatchStep.java   
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));
    }
  }
}
项目:collector    文件:ConfigurationRegistry.java   
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()));
        }
    }
}
项目:configurate    文件:HoconConfigurationLoader.java   
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());
    }
}
项目:kite-morphlines-elasticsearch    文件:LoadElasticsearchBuilderTest.java   
@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);
}
项目:configurate    文件:HoconConfigurationLoader.java   
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());
    }
}
项目:NettyRPC    文件:RPCClient.java   
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;
}
项目:distributeTemplate    文件:ConfigBuilder.java   
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);
}
项目:jooby    文件:ConfigValueResolverTest.java   
@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)));
      });
}
项目:jooby    文件:FtlWrapper.java   
@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);
}
项目:codec    文件:Configs.java   
public static ConfigValue expandSugar(Class<?> type, ConfigValue config,
                                      PluginRegistry pluginRegistry) {
    if ((type != null) && type.isAssignableFrom(ConfigValue.class)) {
        return ConfigValueFactory.fromAnyRef(config.unwrapped(),
                                             "unchanged for raw ConfigValue field "
                                             + config.origin().description());
    }
    CodableClassInfo typeInfo = new CodableClassInfo(type, pluginRegistry.config(), pluginRegistry);
    PluginMap pluginMap = typeInfo.getPluginMap();
    ConfigValue valueOrResolvedRoot = resolveType(type, config, pluginMap);
    if (valueOrResolvedRoot.valueType() != ConfigValueType.OBJECT) {
        return valueOrResolvedRoot;
    }
    ConfigObject root = (ConfigObject) valueOrResolvedRoot;
    String classField = pluginMap.classField();
    if (root.get(classField) != null) {
        try {
            type = pluginMap.getClass((String) root.get(classField).unwrapped());
        } catch (ClassNotFoundException ignored) {
            // try not to throw exceptions or at least checked exceptions from this helper method
        }
    }
    return expandSugarSkipResolve(type, root, pluginRegistry);
}
项目:bandwidth-on-demand    文件:AppComponents.java   
/**
 * Maps the incoming 'reply-to' host+port to our local stunnel port (which in turn delivers the message at the
 * original reply-to address)
 */
@Bean(name = "stunnelTranslationMap")
@Profile("stunnel")
public Optional<Map<String, String>> stunnelTranslationMap() {
  final Config configFile = ConfigFactory.load("stunnel-port-mappings");
  if (!configFile.hasPath("nsi.tlsmap")) {
    throw new IllegalStateException("stunnel port mappings config file does not contain required nsi.tlsmap entry");
  }
  final ConfigObject stunnelConfig = configFile.getObject("nsi.tlsmap");
  LOGGER.debug("Successfully read stunnel-port-mappings.conf");

  Map<String, String> entries = stunnelConfig.entrySet().stream()
      .collect(toMap(entry -> entry.getKey(), entry -> (String) entry.getValue().unwrapped()));

  return Optional.of(ImmutableMap.copyOf(entries));
}
项目:jackson-dataformat-hocon    文件:HoconTreeTraversingParser.java   
public HoconTreeTraversingParser(ConfigObject n, ObjectCodec codec)
{
    super(0);
    _rootObject = n;
    _objectCodec = codec;
    if (n.valueType() == ConfigValueType.LIST) {
        _nextToken = JsonToken.START_ARRAY;
        _nodeCursor = new HoconNodeCursor.Array(n, null);
    } else if (n.valueType() == ConfigValueType.OBJECT) {
        if (HoconNodeCursor.isNumericallyIndexed(n)) {
            _nextToken = JsonToken.START_ARRAY;
            _nodeCursor = new HoconNodeCursor.NumericallyIndexedObjectBackedArray(n, null);
        } else {
            _nextToken = JsonToken.START_OBJECT;
            _nodeCursor = new HoconNodeCursor.Object(n, null);
        }
    } else { // value node
        _nodeCursor = new HoconNodeCursor.RootValue(n, null);
    }
}
项目:Stargraph    文件:Rules.java   
private Map<Language, List<DataModelTypePattern>> loadDataModelTypePatterns(Config config) {
    Map<Language, List<DataModelTypePattern>> rulesByLang = new HashMap<>();
    ConfigObject configObject = config.getObject("rules.syntatic-pattern");

    configObject.keySet().forEach(strLang -> {
        Language language = Language.valueOf(strLang.toUpperCase());

        rulesByLang.compute(language, (l, r) -> {

            List<DataModelTypePattern> rules = new ArrayList<>();
            List<? extends Config> patternCfg = configObject.toConfig().getConfigList(strLang);

            for (Config cfg : patternCfg) {
                Map.Entry<String, ConfigValue> entry = cfg.entrySet().stream().findFirst().orElse(null);
                String modelStr = entry.getKey();
                @SuppressWarnings("unchecked")
                List<String> patternList = (List<String>) entry.getValue().unwrapped();
                rules.addAll(patternList.stream()
                        .map(p -> new DataModelTypePattern(p, DataModelType.valueOf(modelStr)))
                        .collect(Collectors.toList()));
            }

            logger.info(marker, "Loaded {} Data Model Type patterns for '{}'", rules.size(), l);

            return rules;
        });
    });


    return rulesByLang;
}
项目:Stargraph    文件:Rules.java   
private Map<Language, List<QueryTypePatterns>> loadQueryTypePatterns(Config config) {
    Map<Language, List<QueryTypePatterns>> rulesByLang = new HashMap<>();
    ConfigObject configObject = config.getObject("rules.query-pattern");

    configObject.keySet().forEach(strLang -> {
        Language language = Language.valueOf(strLang.toUpperCase());

        ConfigObject innerCfg = configObject.toConfig().getObject(strLang);

        List<QueryTypePatterns> patterns = new ArrayList<>();

        rulesByLang.compute(language, (l, q) -> {
            innerCfg.keySet().forEach(key -> {
                QueryType queryType = QueryType.valueOf(key);
                List<String> patternStr = innerCfg.toConfig().getStringList(key);
                patterns.add(new QueryTypePatterns(queryType,
                        patternStr.stream().map(Pattern::compile).collect(Collectors.toList())));
            });

            logger.info(marker, "Loaded {} Query Type patterns for '{}'", patterns.size(), language);
            return patterns;
        });

    });

    return rulesByLang;
}
项目:xrpc    文件:XConfig.java   
private void populateClientOverrideList(List<? extends ConfigObject> req_per_second_override) {
  req_per_second_override.forEach(
      xs -> {
        xs.forEach(
            (key, value) -> {
              List<String> valString = Arrays.asList(value.unwrapped().toString().split(":"));
              List<Double> val = new ArrayList();
              valString.forEach(v -> val.add(Double.parseDouble(v)));

              clientRateLimitOverride.put(key, val);
            });
      });
}
项目:talchain    文件:SystemProperties.java   
@ValidateMe
public List<Node> peerActive() {
    if (!config.hasPath("peer.active")) {
        return Collections.EMPTY_LIST;
    }
    List<Node> ret = new ArrayList<>();
    List<? extends ConfigObject> list = config.getObjectList("peer.active");
    for (ConfigObject configObject : list) {
        Node n;
        if (configObject.get("url") != null) {
            String url = configObject.toConfig().getString("url");
            n = new Node(url.startsWith("enode://") ? url : "enode://" + url);
        } else if (configObject.get("ip") != null) {
            String ip = configObject.toConfig().getString("ip");
            int port = configObject.toConfig().getInt("port");
            byte[] nodeId;
            if (configObject.toConfig().hasPath("nodeId")) {
                nodeId = Hex.decode(configObject.toConfig().getString("nodeId").trim());
                if (nodeId.length != 64) {
                    throw new RuntimeException("Invalid config nodeId '" + nodeId + "' at " + configObject);
                }
            } else {
                if (configObject.toConfig().hasPath("nodeName")) {
                    String nodeName = configObject.toConfig().getString("nodeName").trim();
                    // FIXME should be keccak-512 here ?
                    nodeId = ECKey.fromPrivate(HashUtil.sha3(nodeName.getBytes())).getNodeId();
                } else {
                    throw new RuntimeException("Either nodeId or nodeName should be specified: " + configObject);
                }
            }
            n = new Node(nodeId, ip, port);
        } else {
            throw new RuntimeException("Unexpected element within 'peer.active' config list: " + configObject);
        }
        ret.add(n);
    }
    return ret;
}
项目:tscfg-docgen    文件:Configuration.java   
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;
}
项目:rskj    文件:RskSystemProperties.java   
public List<ModuleDescription> getRpcModules() {
    if (this.moduleDescriptions != null) {
        return this.moduleDescriptions;
    }

    List<ModuleDescription> modules = new ArrayList<>();

    if (!configFromFiles.hasPath("rpc.modules")) {
        return modules;
    }

    List<? extends ConfigObject> list = configFromFiles.getObjectList("rpc.modules");

    for (ConfigObject configObject : list) {
        Config configElement = configObject.toConfig();
        String name = configElement.getString("name");
        String version = configElement.getString("version");
        boolean enabled = configElement.getBoolean("enabled");
        List<String> enabledMethods = null;
        List<String> disabledMethods = null;

        if (configElement.hasPath("methods.enabled")) {
            enabledMethods = configElement.getStringList("methods.enabled");
        }

        if (configElement.hasPath("methods.disabled")) {
            disabledMethods = configElement.getStringList("methods.disabled");
        }

        modules.add(new ModuleDescription(name, version, enabled, enabledMethods, disabledMethods));
    }

    this.moduleDescriptions = modules;

    return modules;
}
项目:oryx2    文件:ConfigToProperties.java   
private static void add(ConfigObject config, String prefix, Map<String,String> values) {
  config.forEach((key, value) -> {
    String nextPrefix = prefix + "." + key;
    switch (value.valueType()) {
      case OBJECT:
        add((ConfigObject) value, nextPrefix, values);
        break;
      case NULL:
        // do nothing
        break;
      default:
        values.put(nextPrefix, String.valueOf(value.unwrapped()));
    }
  });
}
项目:openrouteservice    文件:AppConfig.java   
public List<? extends ConfigObject> getObjectList(String serviceName, String paramName)
{
    try
    {
        return _config.getObjectList("ors.services." + serviceName + "." + paramName);
    }
    catch(ConfigException ex)
    {}

    return null;
}
项目:hashsdn-controller    文件:FileModuleShardConfigProvider.java   
private static void readModulesConfig(final Config modulesConfig,
        final Map<String, ModuleConfig.Builder> moduleConfigMap, final Configuration configuration) {
    final List<? extends ConfigObject> modulesConfigObjectList = modulesConfig.getObjectList("modules");

    for (final ConfigObject o : modulesConfigObjectList) {
        final ConfigObjectWrapper wrapper = new ConfigObjectWrapper(o);

        final String moduleName = wrapper.stringValue("name");
        final ModuleConfig.Builder builder = moduleConfigMap.computeIfAbsent(moduleName, ModuleConfig::builder);

        builder.nameSpace(wrapper.stringValue("namespace"));
        builder.shardStrategy(ShardStrategyFactory.newShardStrategyInstance(moduleName,
                wrapper.stringValue("shard-strategy"), configuration));
    }
}
项目:-deprecated-hlp-candidate    文件:HoconModule.java   
public HoconModule() {
    super("Hocon");

    this.addDeserializer(ConfigValue.class, HoconDeserializer.CONFIG_VALUE);
    this.addDeserializer(ConfigObject.class, HoconDeserializer.CONFIG_OBJECT);
    this.addDeserializer(ConfigList.class, HoconDeserializer.CONFIG_LIST);
    this.addDeserializer(Config.class, HoconDeserializer.CONFIG);
}
项目:-deprecated-hlp-candidate    文件:HoconDeserializerTest.java   
@Test
public void testSimpleObject() throws Exception {
    final String JSON = "{\"a\":12.5,\"b\":\"Text\"}";
    ConfigObject value = MAPPER.readValue(JSON, ConfigObject.class);
    assertEquals(ConfigValueType.OBJECT, value.valueType());
    assertEquals(2, value.size());

    assertEquals(ConfigValueType.NUMBER, value.get("a").valueType());
    assertEquals(12.5, value.get("a").unwrapped());
    assertEquals(ConfigValueType.STRING, value.get("b").valueType());
    assertEquals("Text", value.get("b").unwrapped());
}
项目:mpush    文件:ConfigBeanImpl.java   
private static Object getListValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, Config config, String configPropName) {
    Type elementType = ((ParameterizedType) parameterType).getActualTypeArguments()[0];

    if (elementType == Boolean.class) {
        return config.getBooleanList(configPropName);
    } else if (elementType == Integer.class) {
        return config.getIntList(configPropName);
    } else if (elementType == Double.class) {
        return config.getDoubleList(configPropName);
    } else if (elementType == Long.class) {
        return config.getLongList(configPropName);
    } else if (elementType == String.class) {
        return config.getStringList(configPropName);
    } else if (elementType == Duration.class) {
        return config.getDurationList(configPropName);
    } else if (elementType == ConfigMemorySize.class) {
        return config.getMemorySizeList(configPropName);
    } else if (elementType == Object.class) {
        return config.getAnyRefList(configPropName);
    } else if (elementType == Config.class) {
        return config.getConfigList(configPropName);
    } else if (elementType == ConfigObject.class) {
        return config.getObjectList(configPropName);
    } else if (elementType == ConfigValue.class) {
        return config.getList(configPropName);
    } else {
        throw new ConfigException.BadBean("Bean property '" + configPropName + "' of class " + beanClass.getName() + " has unsupported list element type " + elementType);
    }
}
项目:mpush    文件:ConfigBeanImpl.java   
private static ConfigValueType getValueTypeOrNull(Class<?> parameterClass) {
    if (parameterClass == Boolean.class || parameterClass == boolean.class) {
        return ConfigValueType.BOOLEAN;
    } else if (parameterClass == Integer.class || parameterClass == int.class) {
        return ConfigValueType.NUMBER;
    } else if (parameterClass == Double.class || parameterClass == double.class) {
        return ConfigValueType.NUMBER;
    } else if (parameterClass == Long.class || parameterClass == long.class) {
        return ConfigValueType.NUMBER;
    } else if (parameterClass == String.class) {
        return ConfigValueType.STRING;
    } else if (parameterClass == Duration.class) {
        return null;
    } else if (parameterClass == ConfigMemorySize.class) {
        return null;
    } else if (parameterClass == List.class) {
        return ConfigValueType.LIST;
    } else if (parameterClass == Map.class) {
        return ConfigValueType.OBJECT;
    } else if (parameterClass == Config.class) {
        return ConfigValueType.OBJECT;
    } else if (parameterClass == ConfigObject.class) {
        return ConfigValueType.OBJECT;
    } else if (parameterClass == ConfigList.class) {
        return ConfigValueType.LIST;
    } else {
        return null;
    }
}
项目:mpush    文件:ConfigCenterTest.java   
public static void print2(String s, ConfigValue configValue, String p, int level) {
    int l = level + 1;
    switch (configValue.valueType()) {
        case OBJECT:
            printTab(level);
            System.out.printf("interface %s {%n", s.replace('-', '_'));
            printTab(level);
            System.out.printf("    Config cfg = %s.cfg.getObject(\"%s\").toConfig();%n%n", p, s);
            ((ConfigObject) configValue).forEach((s1, configValue2) -> print2(s1, configValue2, s, l));
            printTab(level);
            System.out.printf("}%n%n");
            break;
        case STRING:
            printTab(level);
            System.out.printf("  String %s = cfg.getString(\"%s\");%n%n", s.replace('-', '_'), s);
            break;
        case NUMBER:
            printTab(level);
            System.out.printf("  Number %s = cfg.getNumber(\"%s\");%n%n", s.replace('-', '_'), s);
            break;
        case BOOLEAN:
            printTab(level);
            System.out.printf("  Boolean %s = cfg.getBoolean(\"%s\");%n%n", s.replace('-', '_'), s);
            break;
        case LIST:
            printTab(level);
            System.out.printf("  List<Object> %s = cfg.getList(\"%s\").unwrapped();%n%n", s.replace('-', '_'), s);
            break;
    }
}
项目:pdfcompare    文件:Exclusions.java   
private void readFromConfig(final Config load) {
    final List<? extends ConfigObject> exclusions = load.getObjectList("exclusions");
    exclusions.stream().map(co -> {
        final Config c = co.toConfig();
        if (!c.hasPath("x1") && !c.hasPath("y1") && !c.hasPath("x2") && !c.hasPath("y2")) {
            return new Exclusion(c.getInt("page"));
        }
        if (c.hasPath("page")) {
            return new Exclusion(c.getInt("page"), toPix(c, "x1"), toPix(c, "y1"), toPix(c, "x2"), toPix(c,"y2"));
        }
        return new Exclusion(toPix(c, "x1"), toPix(c, "y1"), toPix(c, "x2"), toPix(c,"y2"));
    }).forEach(e -> add(e));
}
项目:vos_backend    文件:Configuration.java   
/**
 * Retrieves a configuration value as a {@code List<Map<String, Object>>}.
 *
 * @param key configuration key (relative to configuration root key)
 * @return a configuration value or <code>null</code>
 */        
public List<Map<String, Object>> getObjectList(String key) {
    if (conf.getObjectList(key).isDefined()) {
      List<Map<String, Object>> out = new ArrayList<Map<String, Object>>();
      for (ConfigObject c : conf.getObjectList(key).get()) {
        out.add(c.unwrapped());
      }
      return out;
    }
    return null;
}
项目:envelope    文件:CheckSchemaDatasetRule.java   
@Override
public void configure(String name, Config config) {
  this.name = name;
  ConfigUtils.assertConfig(config, FIELDS_CONFIG);
  List<? extends ConfigObject> fields = config.getObjectList(FIELDS_CONFIG);
  requiredSchema = parseSchema(fields);
  if (config.hasPath(EXACT_MATCH_CONFIG)) {
    exactMatch = config.getBoolean(EXACT_MATCH_CONFIG);
  }
}
项目:envelope    文件:CheckSchemaDatasetRule.java   
private static StructType parseSchema(List<? extends ConfigObject> fieldsConfig) {
  StructField[] fields = new StructField[fieldsConfig.size()];
  for (int i = 0; i < fieldsConfig.size(); i++) {
    fields[i] = parseField(fieldsConfig.get(i).toConfig());
  }
  return new StructType(fields);
}