org.apache.gobblin.configuration.State.getPropAsSet()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.apache.gobblin.configuration.State.getPropAsSet()方法的一些代码示例,展示了State.getPropAsSet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。State.getPropAsSet()方法的具体详情如下:
包路径:org.apache.gobblin.configuration.State
类名称:State
方法名:getPropAsSet

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()));
   }
  }
 }
}

相关文章