本文整理了Java中org.apache.gobblin.configuration.State.getPropAsSet()
方法的一些代码示例,展示了State.getPropAsSet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。State.getPropAsSet()
方法的具体详情如下:
包路径:org.apache.gobblin.configuration.State
类名称:State
方法名:getPropAsSet
[英]Get the value of a comma separated property as a Set of strings.
[中]以字符串集的形式获取逗号分隔属性的值。
代码示例来源:origin: apache/incubator-gobblin
/**
* Appends the input value to a set property that can be retrieved with {@link #getPropAsSet}.
*
* <p>
* Set properties are internally stored as comma separated strings. Adding a value that contains commas (for
* example "a,b,c") will essentially add multiple values to the property ("a", "b", and "c"). This is
* similar to the way that {@link org.apache.hadoop.conf.Configuration} works.
* </p>
*
* @param key property key
* @param value property value (if it includes commas, it will be split by the commas).
*/
public synchronized void appendToSetProp(String key, String value) {
Set<String> set = value == null ? Sets.<String>newHashSet() : Sets.newHashSet(LIST_SPLITTER.splitToList(value));
if (contains(key)) {
set.addAll(getPropAsSet(key));
}
setProp(key, LIST_JOINER.join(set));
}
代码示例来源:origin: apache/incubator-gobblin
private void addServicesFromProperties(Properties properties)
throws IllegalAccessException, InstantiationException, ClassNotFoundException, InvocationTargetException {
if (properties.containsKey(APP_ADDITIONAL_SERVICES)) {
for (String serviceClassName : new State(properties).getPropAsSet(APP_ADDITIONAL_SERVICES)) {
Class<?> serviceClass = Class.forName(serviceClassName);
if (Service.class.isAssignableFrom(serviceClass)) {
Service service;
Constructor<?> constructor =
ConstructorUtils.getMatchingAccessibleConstructor(serviceClass, Properties.class);
if (constructor != null) {
service = (Service) constructor.newInstance(properties);
} else {
service = (Service) serviceClass.newInstance();
}
addService(service);
} else {
throw new IllegalArgumentException(String.format("Class %s specified by %s does not implement %s",
serviceClassName, APP_ADDITIONAL_SERVICES, Service.class.getSimpleName()));
}
}
}
}
代码示例来源:origin: org.apache.gobblin/gobblin-api
/**
* Appends the input value to a set property that can be retrieved with {@link #getPropAsSet}.
*
* <p>
* Set properties are internally stored as comma separated strings. Adding a value that contains commas (for
* example "a,b,c") will essentially add multiple values to the property ("a", "b", and "c"). This is
* similar to the way that {@link org.apache.hadoop.conf.Configuration} works.
* </p>
*
* @param key property key
* @param value property value (if it includes commas, it will be split by the commas).
*/
public synchronized void appendToSetProp(String key, String value) {
Set<String> set = value == null ? Sets.<String>newHashSet() : Sets.newHashSet(LIST_SPLITTER.splitToList(value));
if (contains(key)) {
set.addAll(getPropAsSet(key));
}
setProp(key, LIST_JOINER.join(set));
}
代码示例来源:origin: org.apache.gobblin/gobblin-runtime
private void addServicesFromProperties(Properties properties)
throws IllegalAccessException, InstantiationException, ClassNotFoundException, InvocationTargetException {
if (properties.containsKey(APP_ADDITIONAL_SERVICES)) {
for (String serviceClassName : new State(properties).getPropAsSet(APP_ADDITIONAL_SERVICES)) {
Class<?> serviceClass = Class.forName(serviceClassName);
if (Service.class.isAssignableFrom(serviceClass)) {
Service service;
Constructor<?> constructor =
ConstructorUtils.getMatchingAccessibleConstructor(serviceClass, Properties.class);
if (constructor != null) {
service = (Service) constructor.newInstance(properties);
} else {
service = (Service) serviceClass.newInstance();
}
addService(service);
} else {
throw new IllegalArgumentException(String.format("Class %s specified by %s does not implement %s",
serviceClassName, APP_ADDITIONAL_SERVICES, Service.class.getSimpleName()));
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!