@Test public void canCalculateIfPriceIsBetweenOtherPrices() { assertThat(new Price(10).isBetweenInclusive(new Price(5), new Price(15))).isTrue(); assertThat(new Price(10).isBetweenInclusive(new Price(15), new Price(5))).isTrue(); assertThat(new Price(10).isBetweenInclusive(new Price(150), new Price(50))).isFalse(); assertThat(new Price(10).isBetweenInclusive(new Price(11), new Price(10))).isTrue(); assertThat(new Price(10).isBetweenInclusive(new Price(10), new Price(11))).isTrue(); assertThat(new Price(10).isBetweenInclusive(new Price(10), new Price(10))).isTrue(); assertThat(new Price(0).isBetweenInclusive(new Price(-1), new Price(1))).isTrue(); assertThat(new Price(-21).isBetweenInclusive(new Price(-1), new Price(-30))).isTrue(); assertThat(new Price(-21).isBetweenInclusive(new Price(-31), new Price(-30))).isFalse(); }
public boolean isBetweenInclusive(final Price a, final Price b) { final long min = a.price < b.price ? a.price : b.price; final long max = a.price > b.price ? a.price : b.price; return price >= min && price <= max; }
Price implements Comparable<Price> { public boolean isBetweenInclusive(final Price a, final Price b) { final long min = a.price < b.price ? a.price : b.price; final long max = a.price > b.price ? a.price : b.price; return price >= min && price <= max; } }
Price implements Comparable<Price> { public boolean isBetweenInclusive(final Price a, final Price b) { final long min = a.price < b.price ? a.price : b.price; final long max = a.price > b.price ? a.price : b.price; return price >= min && price <= max; } Price(final double price);  Price(final long price);  Price(final long value, final PriceUnit unit); }
Price implements Comparable<Price> { public boolean isBetweenInclusive(final Price a, final Price b) { final long min = a.price < b.price ? a.price : b.price; final long max = a.price > b.price ? a.price : b.price; return price >= min && price <= max; } Price(final double price);  Price(final long price);  Price(final long value, final PriceUnit unit); long asPipette(); double asDouble(); Price plus(final Price other); Price plus(final int amount, final PriceUnit unit); Price plus(final double value, final RatioUnit unit); Price plus(final Ratio ratio); Price minus(final Price other); Price minus(final int amount, final PriceUnit unit); Price minus(final double value, final RatioUnit unit); Price minus(final Ratio ratio); Price inverse(); Price absolute(); Price multiply(final Ratio ratio); Money multiply(final Volume volume, final Currency currency); Ratio divide(final Price divisor); boolean isLessThan(final Price other); boolean isGreaterThan(final Price other); boolean isStrongerThan(final Price other, final MarketDirection direction); boolean isWeakerThan(final Price other, final MarketDirection direction); boolean isBetweenInclusive(final Price a, final Price b); @Override boolean equals(final Object other); @Override int compareTo(final Price other); @Override int hashCode(); String toStringWithSign(); @Override String toString(); }
Price implements Comparable<Price> { public boolean isBetweenInclusive(final Price a, final Price b) { final long min = a.price < b.price ? a.price : b.price; final long max = a.price > b.price ? a.price : b.price; return price >= min && price <= max; } Price(final double price);  Price(final long price);  Price(final long value, final PriceUnit unit); long asPipette(); double asDouble(); Price plus(final Price other); Price plus(final int amount, final PriceUnit unit); Price plus(final double value, final RatioUnit unit); Price plus(final Ratio ratio); Price minus(final Price other); Price minus(final int amount, final PriceUnit unit); Price minus(final double value, final RatioUnit unit); Price minus(final Ratio ratio); Price inverse(); Price absolute(); Price multiply(final Ratio ratio); Money multiply(final Volume volume, final Currency currency); Ratio divide(final Price divisor); boolean isLessThan(final Price other); boolean isGreaterThan(final Price other); boolean isStrongerThan(final Price other, final MarketDirection direction); boolean isWeakerThan(final Price other, final MarketDirection direction); boolean isBetweenInclusive(final Price a, final Price b); @Override boolean equals(final Object other); @Override int compareTo(final Price other); @Override int hashCode(); String toStringWithSign(); @Override String toString();  }