/** * Sets allowed maximum value as decimal string or percent representation. * The given precision is also considered in error messages. Coverage ratios * are given in the range from 0.0 to 1.0. * * @param maximum * allowed maximum or <code>null</code>, if no maximum should be * checked */ public void setMaximum(final String maximum) { this.maximum = parseValue(maximum); }
/** * Creates and adds a new {@link Limit}. * * @return creates {@link Limit} */ public Limit createLimit() { final Limit limit = new Limit(); this.limits.add(limit); return limit; }
private void checkLimit(final ICoverageNode node, final String elementtype, final String typename, final Rule rule, final Limit limit) { final String message = limit.check(node); if (message != null) { output.onViolation(node, rule, limit, String.format( "Rule violated for %s %s: %s", elementtype, typename, message)); } }
String check(final ICoverageNode node) { final double d = node.getCounter(entity).getValue(value); if (Double.isNaN(d)) { return null; } final BigDecimal bd = BigDecimal.valueOf(d); if (minimum != null && minimum.compareTo(bd) > 0) { return message("minimum", bd, minimum, RoundingMode.FLOOR); } if (maximum != null && maximum.compareTo(bd) < 0) { return message("maximum", bd, maximum, RoundingMode.CEILING); } return null; }
/** * Sets allowed maximum value as decimal string or percent representation. * The given precision is also considered in error messages. Coverage ratios * are given in the range from 0.0 to 1.0. * * @param minimum * allowed minimum or <code>null</code>, if no minimum should be * checked */ public void setMinimum(final String minimum) { this.minimum = parseValue(minimum); }