org.apache.gobblin.metrics.Tag.fromString()方法的使用及代码示例

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

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

Tag.fromString介绍

[英]Reverse of Tag.toString(). Parses a string of the form "key:value" into a Tag.

If there are multiple ":" in the input string, the key will be the substring up to the first ":", and the value will be the substring after the first ":".
[中]标签的反面。toString()。将形式为“key:value”的字符串解析为标记。
如果输入字符串中有多个“:”,则键将是第一个“:”之前的子字符串,值将是第一个“:”之后的子字符串。

代码示例

代码示例来源:origin: apache/incubator-gobblin

/**
 * Parse custom {@link org.apache.gobblin.metrics.Tag}s from property {@link #METRICS_STATE_CUSTOM_TAGS}
 * in the input {@link org.apache.gobblin.configuration.State}.
 * @param state {@link org.apache.gobblin.configuration.State} possibly containing custom tags.
 * @return List of {@link org.apache.gobblin.metrics.Tag} parsed from input.
 */
public static List<Tag<?>> getCustomTagsFromState(State state) {
 List<Tag<?>> tags = Lists.newArrayList();
 for (String tagKeyValue : state.getPropAsList(METRICS_STATE_CUSTOM_TAGS, "")) {
  Tag<?> tag = Tag.fromString(tagKeyValue);
  if (tag != null) {
   tags.add(tag);
  }
 }
 return tags;
}

代码示例来源:origin: org.apache.gobblin/gobblin-metrics

/**
 * Parse custom {@link org.apache.gobblin.metrics.Tag}s from property {@link #METRICS_STATE_CUSTOM_TAGS}
 * in the input {@link org.apache.gobblin.configuration.State}.
 * @param state {@link org.apache.gobblin.configuration.State} possibly containing custom tags.
 * @return List of {@link org.apache.gobblin.metrics.Tag} parsed from input.
 */
public static List<Tag<?>> getCustomTagsFromState(State state) {
 List<Tag<?>> tags = Lists.newArrayList();
 for (String tagKeyValue : state.getPropAsList(METRICS_STATE_CUSTOM_TAGS, "")) {
  Tag<?> tag = Tag.fromString(tagKeyValue);
  if (tag != null) {
   tags.add(tag);
  }
 }
 return tags;
}

相关文章