本文整理匯總了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;
}