private static boolean hasOnlyZeroVariations(MeasureVariations variations) { return (!variations.hasVariation1() || NumberUtils.compare(variations.getVariation1(), 0.0) == 0) && (!variations.hasVariation2() || NumberUtils.compare(variations.getVariation2(), 0.0) == 0) && (!variations.hasVariation3() || NumberUtils.compare(variations.getVariation3(), 0.0) == 0) && (!variations.hasVariation4() || NumberUtils.compare(variations.getVariation4(), 0.0) == 0) && (!variations.hasVariation5() || NumberUtils.compare(variations.getVariation5(), 0.0) == 0); }
public boolean match(SourceCode unit) { switch (operator) { case EQUALS: return NumberUtils.compare(unit.getDouble(metric), value) == 0; case GREATER_THAN: return unit.getDouble(metric) > value; case GREATER_THAN_EQUALS: return unit.getDouble(metric) >= value; case LESS_THAN_EQUALS: return unit.getDouble(metric) <= value; case LESS_THAN: return unit.getDouble(metric) < value; default: throw new IllegalStateException("The operator value '" + operator + "' is unknown."); } }
public boolean matches(Object o) { Measure m = (Measure) o; if (metric != null && !ObjectUtils.equals(metric, m.getMetric())) { mismatchTxt = "metric: " + metric.getKey(); return false; } if (value != null && NumberUtils.compare(value, m.getValue()) != 0) { mismatchTxt = "value: " + value; return false; } if (data != null && !ObjectUtils.equals(data, m.getData())) { mismatchTxt = "data: " + data; return false; } return true; }
/** * Compares this mutable to another in ascending order. * * @param obj the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableDouble */ public int compareTo(Object obj) { MutableDouble other = (MutableDouble) obj; double anotherVal = other.value; return NumberUtils.compare(value, anotherVal); }