本文整理汇总了Java中org.boon.Pair类的典型用法代码示例。如果您正苦于以下问题:Java Pair类的具体用法?Java Pair怎么用?Java Pair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pair类属于org.boon包,在下文中一共展示了Pair类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processDocumentAndAddToMetrics
import org.boon.Pair; //导入依赖的package包/类
private List<GraphiteMetric> processDocumentAndAddToMetrics(Document document, String origin) {
if ((document == null) || (origin == null)) {
return new ArrayList<>();
}
List<GraphiteMetric> graphiteMetrics = new ArrayList<>();
try {
document = filterDocument(document, origin);
List<Pair<String, BigDecimal>> metrics = new ArrayList<>();
metrics = buildMetrics(origin, document, metrics);
int metricTimestamp = ((int) (System.currentTimeMillis() / 1000));
for (Pair<String, BigDecimal> pair : metrics) {
String graphiteFriendlyMetricPath = GraphiteMetric.getGraphiteSanitizedString(pair.getFirst(), true, true);
graphiteMetrics.add(new GraphiteMetric(graphiteFriendlyMetricPath, pair.getSecond(), metricTimestamp));
}
}
catch (Exception e) {
logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
}
return graphiteMetrics;
}
示例2: buildMetrics
import org.boon.Pair; //导入依赖的package包/类
private List<Pair<String, BigDecimal>> buildMetrics(String start, Document document, List<Pair<String, BigDecimal>> metrics) {
if ((start == null) || (document == null) || document.isEmpty()) {
return new ArrayList<>();
}
try {
Document documentCopy = Document.parse(document.toJson());
for (Entry entry : document.entrySet()) {
String key = entry.getKey().toString();
if ((documentCopy.get(key) instanceof Integer) || (documentCopy.get(key) instanceof Double) || (documentCopy.get(key) instanceof Long)) {
if (start.isEmpty()) {
metrics.add(new Pair(key, new BigDecimal(documentCopy.get(key).toString())));
}
else {
metrics.add(new Pair(start + "." + key, new BigDecimal(documentCopy.get(key).toString())));
}
}
else if (entry.getValue() instanceof Document) {
Document passdown = (Document) entry.getValue();
if (start.isEmpty()) {
buildMetrics(key, passdown, metrics);
}
else {
buildMetrics(start + "." + key, passdown, metrics);
}
}
}
}
catch (Exception e) {
logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
}
return metrics;
}