當前位置: 首頁>>代碼示例>>Java>>正文


Java Pair類代碼示例

本文整理匯總了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;
    }
 
開發者ID:PearsonEducation,項目名稱:StatsPoller,代碼行數:28,代碼來源:MongoMetricCollector.java

示例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;
    }
 
開發者ID:PearsonEducation,項目名稱:StatsPoller,代碼行數:38,代碼來源:MongoMetricCollector.java


注:本文中的org.boon.Pair類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。