Example usage for org.apache.commons.collections MapUtils getDoubleValue

List of usage examples for org.apache.commons.collections MapUtils getDoubleValue

Introduction

In this page you can find the example usage for org.apache.commons.collections MapUtils getDoubleValue.

Prototype

public static double getDoubleValue(final Map map, final Object key, double defaultValue) 

Source Link

Document

Gets a double from a Map in a null-safe manner, using the default value if the the conversion fails.

Usage

From source file:net.grinder.SingleConsole.java

@Override
public long getCurrentExecutionCount() {
    Map<?, ?> totalStatistics = (Map<?, ?>) getStatisticsData().get("totalStatistics");
    Double testCount = MapUtils.getDoubleValue(totalStatistics, "Tests", 0D);
    Double errorCount = MapUtils.getDoubleValue(totalStatistics, "Errors", 0D);
    return testCount.longValue() + errorCount.longValue();
}

From source file:net.grinder.SingleConsole.java

/**
 * Check if the current test contains too many errors.
 *
 * @return true if error is over 20%/*from   w  ww.j a  va2  s.c o m*/
 */
public boolean hasTooManyError() {
    long currentTestsCount = getCurrentExecutionCount();
    double errors = MapUtils.getDoubleValue((Map<?, ?>) getStatisticsData().get("totalStatistics"), "Errors",
            0D);
    return currentTestsCount != 0 && (errors / currentTestsCount) > 0.2;
}