@Test(expected = IllegalArgumentException.class) public void averageRatioThrowsExceptionWhenIteratorDidNotContainElements() { Ratio.average(asList()); }
public static Ratio average(final Iterable<Ratio> rates) throws IllegalArgumentException { double sum = 0; int count = 0; for (final Ratio rate : rates) { count += 1; sum += rate.value; } if (count == 0) { throw new IllegalArgumentException( "The iterator containing the ratios thats average should be calculated contained no ratios."); } return new Ratio(sum / count); }
Ratio implements Comparable<Ratio> { public static Ratio average(final Iterable<Ratio> rates) throws IllegalArgumentException { double sum = 0; int count = 0; for (final Ratio rate : rates) { count += 1; sum += rate.value; } if (count == 0) { throw new IllegalArgumentException( "The iterator containing the ratios thats average should be calculated contained no ratios."); } return new Ratio(sum / count); } }
Ratio implements Comparable<Ratio> { public static Ratio average(final Iterable<Ratio> rates) throws IllegalArgumentException { double sum = 0; int count = 0; for (final Ratio rate : rates) { count += 1; sum += rate.value; } if (count == 0) { throw new IllegalArgumentException( "The iterator containing the ratios thats average should be calculated contained no ratios."); } return new Ratio(sum / count); } Ratio(final double value);  Ratio(final double value, final RatioUnit unit); }
Ratio implements Comparable<Ratio> { public static Ratio average(final Iterable<Ratio> rates) throws IllegalArgumentException { double sum = 0; int count = 0; for (final Ratio rate : rates) { count += 1; sum += rate.value; } if (count == 0) { throw new IllegalArgumentException( "The iterator containing the ratios thats average should be calculated contained no ratios."); } return new Ratio(sum / count); } Ratio(final double value);  Ratio(final double value, final RatioUnit unit); double asBasic(); static Ratio average(final Iterable<Ratio> rates); @Override int compareTo(final Ratio other); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); }
Ratio implements Comparable<Ratio> { public static Ratio average(final Iterable<Ratio> rates) throws IllegalArgumentException { double sum = 0; int count = 0; for (final Ratio rate : rates) { count += 1; sum += rate.value; } if (count == 0) { throw new IllegalArgumentException( "The iterator containing the ratios thats average should be calculated contained no ratios."); } return new Ratio(sum / count); } Ratio(final double value);  Ratio(final double value, final RatioUnit unit); double asBasic(); static Ratio average(final Iterable<Ratio> rates); @Override int compareTo(final Ratio other); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); static final Ratio MIN_VALUE; }