@Override public List<?> extractListValue(Config config, String path) { return config.getStringList(path); } },
public List<String> getStringList(String path) { return m_config.getStringList(path); }
@Override public List<String> getStringList(String path) { return c.getStringList(path); }
/** * @param config configuration to query for value * @param key configuration path key * @return value for given key, or {@code null} if none exists */ public static List<String> getOptionalStringList(Config config, String key) { return config.hasPath(key) ? config.getStringList(key) : null; }
public List<String> getStringList(String path, List<String> def) { if (m_config.hasPath(path)) return m_config.getStringList(path); else return def; }
public Set<Admission> admission() { return config().getStringList("admission").stream() .map(String::toUpperCase) .map(Admission::valueOf) .collect(toSet()); }
public Set<HillClimberType> strategy() { return config().getStringList("hill-climber-window-tiny-lfu.strategy").stream() .map(strategy -> strategy.replace('-', '_').toUpperCase(US)) .map(HillClimberType::valueOf) .collect(toSet()); }
public Set<String> policies() { return config().getStringList("policies").stream() .map(String::toLowerCase) .collect(toSet()); }
public List<String> paths() { return config().getStringList("files.paths"); } public TraceFormat format() {
public Set<Eviction> policy() { Set<Eviction> policies = new HashSet<>(); for (String policy : config().getStringList("ohc.policy")) { String name = policy.toLowerCase(US).replaceAll("[^a-z]", ""); if (name.equals("lru")) { policies.add(Eviction.LRU); } else if (name.equals("wtinylfu")) { policies.add(Eviction.W_TINY_LFU); } else { throw new IllegalArgumentException("Unknown policy: " + policy); } } return policies; } }
public Stream<Density> density() { return config().getStringList("collision.density").stream() .map(density -> Density.valueOf(density.toUpperCase(US))); } }
@ValidateMe public List<String> peerCapabilities() { return config.getStringList("peer.capabilities"); }
@ValidateMe public List<String> peerDiscoveryIPList() { return config.getStringList("peer.discovery.ip.list"); }
private List<String> strList(final String p) { Object list = mail.getAnyRef(p); if (list instanceof String) { return ImmutableList.of(list.toString()); } return mail.getStringList(p); }
public static CliConfig fromConfig(final Config config) { checkNotNull(config); final Map<String, Object> defaultSettings = ImmutableMap.of( DOMAINS_KEY, EMPTY_STRING_LIST, SRV_NAME_KEY, "helios", MASTER_ENDPOINTS_KEY, EMPTY_STRING_LIST ); final Config configWithDefaults = config.withFallback(ConfigFactory.parseMap(defaultSettings)); final List<String> domains = configWithDefaults.getStringList(DOMAINS_KEY); final String srvName = configWithDefaults.getString(SRV_NAME_KEY); final List<URI> masterEndpoints = Lists.newArrayList(); for (final String endpoint : configWithDefaults.getStringList(MASTER_ENDPOINTS_KEY)) { masterEndpoints.add(URI.create(endpoint)); } return new CliConfig(domains, srvName, masterEndpoints); } }
/** Adds the entry listeners settings. */ private void addListeners() { for (String path : merged.getStringList("listeners")) { Config listener = root.getConfig(path); Factory<? extends CacheEntryListener<? super K, ? super V>> listenerFactory = factoryCreator.factoryOf(listener.getString("class")); Factory<? extends CacheEntryEventFilter<? super K, ? super V>> filterFactory = null; if (listener.hasPath("filter")) { filterFactory = factoryCreator.factoryOf(listener.getString("filter")); } boolean oldValueRequired = listener.getBoolean("old-value-required"); boolean synchronous = listener.getBoolean("synchronous"); configuration.addCacheEntryListenerConfiguration( new MutableCacheEntryListenerConfiguration<>( listenerFactory, filterFactory, oldValueRequired, synchronous)); } }
public Builder withReplicationReplica(Config config) throws InstantiationException, IllegalAccessException, ClassNotFoundException { Preconditions.checkArgument(config.hasPath(REPLICATION_REPLICAS), "missing required config entery " + REPLICATION_REPLICAS); Config replicasConfig = config.getConfig(REPLICATION_REPLICAS); Preconditions.checkArgument(replicasConfig.hasPath(REPLICATOIN_REPLICAS_LIST), "missing required config entery " + REPLICATOIN_REPLICAS_LIST); List<String> replicaNames = replicasConfig.getStringList(REPLICATOIN_REPLICAS_LIST); for (String replicaName : replicaNames) { Preconditions.checkArgument(replicasConfig.hasPath(replicaName), "missing replica name " + replicaName); Config subConfig = replicasConfig.getConfig(replicaName); // each replica could have own EndPointFactory resolver String endPointFactory = subConfig.hasPath(END_POINT_FACTORY_CLASS) ? subConfig.getString(END_POINT_FACTORY_CLASS) : DEFAULT_END_POINT_FACTORY_CLASS; EndPointFactory factory = endPointFactoryResolver.resolveClass(endPointFactory).newInstance(); this.replicas.add(factory.buildReplica(subConfig, replicaName, this.selectionConfig)); } return this; }
@Inject MetricsConfig(Config config) { this.config = config; if (config.hasPath("metrics.server")) { enabledMetrics = parseConfig(config.getStringList("metrics.server")); } else { enabledMetrics = DEFAULT_ENABLED_METRICS; } if (config.hasPath("metrics.precreate-codes")) { precreateCodes = new HashSet<>(config.getIntList("metrics.precreate-codes")); } else { precreateCodes = Collections.emptySet(); } durationThresholdConfig = DurationThresholdConfig.parseConfig(config); }
return ConfigFactory.parseString(includesBuilder.toString()).withFallback(ConfigFactory.defaultOverrides()) .withFallback(ConfigFactory.systemEnvironment()).withFallback(runtimeConfig.get()).resolve() .getStringList(INCLUDES_KEY_NAME); } else { return ConfigFactory.parseString(includesBuilder.toString()).withFallback(ConfigFactory.defaultOverrides()) .withFallback(ConfigFactory.systemEnvironment()).resolve().getStringList(INCLUDES_KEY_NAME);
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); } }