Java Code Examples for com.typesafe.config.Config#getConfigList()
The following examples show how to use
com.typesafe.config.Config#getConfigList() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigurableCleanableDataset.java From incubator-gobblin with Apache License 2.0 | 6 votes |
/** * Creates a new ConfigurableCleanableDataset configured through gobblin-config-management. The constructor expects * {@link #VERSION_FINDER_CLASS_KEY} and {@link #RETENTION_POLICY_CLASS_KEY} to be available in the * <code>config</code> passed. */ public ConfigurableCleanableDataset(FileSystem fs, Properties jobProps, Path datasetRoot, Config config, Logger log) throws IOException { super(fs, jobProps, config, log); this.datasetRoot = datasetRoot; this.versionFindersAndPolicies = Lists.newArrayList(); if (config.hasPath(DATASET_VERSION_POLICY_ALIAS)) { initWithSelectionPolicy(config.getConfig(DATASET_VERSION_POLICY_ALIAS), jobProps); } else if (config.hasPath(VERSION_FINDER_CLASS_KEY) && config.hasPath(RETENTION_POLICY_CLASS_KEY)) { initWithRetentionPolicy(config, jobProps, RETENTION_POLICY_CLASS_KEY, VERSION_FINDER_CLASS_KEY); } else if (config.hasPath(VERSION_FINDER_CLASS_KEY)) { initWithSelectionPolicy(config.getConfig(RETENTION_CONFIGURATION_KEY), jobProps); } else if (config.hasPath(DATASET_PARTITIONS_LIST_KEY)) { List<? extends Config> versionAndPolicies = config.getConfigList(DATASET_PARTITIONS_LIST_KEY); for (Config versionAndPolicy : versionAndPolicies) { initWithSelectionPolicy(versionAndPolicy, jobProps); } } else { throw new IllegalArgumentException( String.format("Either set version finder at %s and retention policy at %s or set partitions at %s", VERSION_FINDER_CLASS_KEY, RETENTION_POLICY_CLASS_KEY, DATASET_PARTITIONS_LIST_KEY)); } }
Example 2
Source File: ResourcePoolSelectorFactory.java From Bats with Apache License 2.0 | 5 votes |
public static ResourcePoolSelector createSelector(Config selectorConfig) throws RMConfigException { ResourcePoolSelector poolSelector = null; String selectorType = SelectorType.DEFAULT.toString(); try { if (selectorConfig == null) { poolSelector = new DefaultSelector(); } else if (selectorConfig.hasPath(SelectorType.TAG.toString())) { selectorType = SelectorType.TAG.toString(); poolSelector = new TagSelector(selectorConfig.getString(selectorType)); } else if (selectorConfig.hasPath(SelectorType.ACL.toString())) { selectorType = SelectorType.ACL.toString(); poolSelector = new AclSelector(selectorConfig.getConfig(selectorType)); } else if (selectorConfig.hasPath(SelectorType.OR.toString())) { selectorType = SelectorType.OR.toString(); poolSelector = new OrSelector(selectorConfig.getConfigList(selectorType)); } else if (selectorConfig.hasPath(SelectorType.AND.toString())) { selectorType = SelectorType.AND.toString(); poolSelector = new AndSelector(selectorConfig.getConfigList(selectorType)); } else if (selectorConfig.hasPath(SelectorType.NOT_EQUAL.toString())) { selectorType = SelectorType.NOT_EQUAL.toString(); poolSelector = new NotEqualSelector(selectorConfig.getConfig(selectorType)); } } catch (Exception ex) { throw new RMConfigException(String.format("There is an error with value configuration for selector type %s", selectorType), ex); } // if here means either a selector is chosen or wrong configuration if (poolSelector == null) { throw new RMConfigException(String.format("Configured selector is either empty or not supported. [Details: " + "SelectorConfig: %s]", selectorConfig)); } logger.debug("Created selector of type {}", poolSelector.getSelectorType().toString()); return poolSelector; }
Example 3
Source File: ConfigBeanImpl.java From mpush with Apache License 2.0 | 5 votes |
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); } }
Example 4
Source File: EdgeProxyFunctionalTest.java From xio with Apache License 2.0 | 5 votes |
EdgeProxyConfig(Config config) { super(config); List<Config> routes = (List<Config>) config.getConfigList("routes"); routeConfigs = new RouteConfigs<>( routes // iterate over a stream of Config .stream() // for each Config create a ProxyRouteConfig .map(ProxyRouteConfig::new) // collect the stream of ProxyRouteConfig into List<ProxyRouteConfig> .collect(Collectors.toList())); allPermissions = null; }
Example 5
Source File: JmxConfig.java From spectator with Apache License 2.0 | 5 votes |
/** Create a new instance from the Typesafe Config object. */ static JmxConfig from(Config config) { try { ObjectName query = new ObjectName(config.getString("query")); List<JmxMeasurementConfig> ms = new ArrayList<>(); for (Config cfg : config.getConfigList("measurements")) { ms.add(JmxMeasurementConfig.from(cfg)); } return new JmxConfig(query, ms); } catch (Exception e) { throw new IllegalArgumentException("invalid mapping config", e); } }
Example 6
Source File: JMXRemote.java From newrelic-plugins with MIT License | 5 votes |
public JMXRemote(Config config, String pluginName, String pluginVersion) { super(pluginName, pluginVersion); this.name = config.getString("name"); this.host = config.getString("host"); this.port = config.getString("port"); this.JMXList = config.getConfigList("metrics"); this.metricPrefix = "JMX/hosts/" + host +":" + port; }
Example 7
Source File: Configs.java From kite with Apache License 2.0 | 5 votes |
public List<? extends Config> getConfigList(Config config, String path, List<? extends Config> defaults) { addRecognizedArgument(path); if (config.hasPath(path)) { return config.getConfigList(path); } else { return defaults; } }
Example 8
Source File: Compiler.java From kite with Apache License 2.0 | 5 votes |
/** * Finds the given morphline id within the given morphline config, using the given nameForErrorMsg * for error reporting. */ public Config find(String morphlineId, Config config, String nameForErrorMsg) { List<? extends Config> morphlineConfigs = config.getConfigList("morphlines"); if (morphlineConfigs.size() == 0) { throw new MorphlineCompilationException( "Morphline file must contain at least one morphline: " + nameForErrorMsg, null); } if (morphlineId != null) { morphlineId = morphlineId.trim(); } if (morphlineId != null && morphlineId.length() == 0) { morphlineId = null; } Config morphlineConfig = null; if (morphlineId == null) { morphlineConfig = morphlineConfigs.get(0); Preconditions.checkNotNull(morphlineConfig); } else { for (Config candidate : morphlineConfigs) { if (morphlineId.equals(new Configs().getString(candidate, "id", null))) { morphlineConfig = candidate; break; } } if (morphlineConfig == null) { throw new MorphlineCompilationException( "Morphline id '" + morphlineId + "' not found in morphline file: " + nameForErrorMsg, null); } } return morphlineConfig; }
Example 9
Source File: Configs.java From kite with Apache License 2.0 | 4 votes |
public List<? extends Config> getConfigList(Config config, String path) { addRecognizedArgument(path); return config.getConfigList(path); }
Example 10
Source File: SimpleHoconConfigTest.java From kite with Apache License 2.0 | 4 votes |
@Test @Ignore public void testBasic() { Config conf = ConfigFactory.load("test-application").getConfig(getClass().getPackage().getName() + ".test"); assertEquals(conf.getString("foo.bar"), "1234"); assertEquals(conf.getInt("foo.bar"), 1234); //assertEquals(conf.getInt("moo.bar"), 56789); // read from reference.config Config subConfig = conf.getConfig("foo"); assertNotNull(subConfig); assertEquals(subConfig.getString("bar"), "1234"); assertFalse(conf.hasPath("missing.foox.barx")); try { conf.getString("missing.foox.barx"); fail("Failed to detect missing param"); } catch (ConfigException.Missing e) {} Iterator userNames = Arrays.asList("nadja", "basti").iterator(); Iterator passwords = Arrays.asList("nchangeit", "bchangeit").iterator(); for (Config user : conf.getConfigList("users")) { assertEquals(user.getString("userName"), userNames.next()); assertEquals(user.getString("password"), passwords.next()); } assertFalse(userNames.hasNext()); assertFalse(passwords.hasNext()); assertEquals(conf.getStringList("files.paths"), Arrays.asList("dir/file1.log", "dir/file2.txt")); Iterator schemas = Arrays.asList("schema1.json", "schema2.json").iterator(); Iterator globs = Arrays.asList("*.log*", "*.txt*").iterator(); for (Config fileMapping : conf.getConfigList("files.fileMappings")) { assertEquals(fileMapping.getString("schema"), schemas.next()); assertEquals(fileMapping.getString("glob"), globs.next()); } assertFalse(schemas.hasNext()); assertFalse(globs.hasNext()); // Object list2 = conf.entrySet(); // Object list2 = conf.getAnyRef("users.userName"); // assertEquals(conf.getString("users.user.userName"), "nadja"); }