@Test public void canCheckIfAGivenPriceLevelIsContained() { final PriceLevels cut = new PriceLevels(new Price(1592), new Price(3951), new Price(-9423)); assertThat(cut.contains(new Price(3951))).isTrue(); assertThat(cut.contains(new Price(-9423))).isTrue(); assertThat(cut.contains(new Price(81))).isFalse(); }
public boolean contains(final Price price) { for (final Price level : priceLevels) { if (level.equals(price)) { return true; } } return false; }
PriceLevels { public boolean contains(final Price price) { for (final Price level : priceLevels) { if (level.equals(price)) { return true; } } return false; } }
PriceLevels { public boolean contains(final Price price) { for (final Price level : priceLevels) { if (level.equals(price)) { return true; } } return false; } PriceLevels(final Price... priceLevels);  PriceLevels(final List<Price> priceLevels); }
PriceLevels { public boolean contains(final Price price) { for (final Price level : priceLevels) { if (level.equals(price)) { return true; } } return false; } PriceLevels(final Price... priceLevels);  PriceLevels(final List<Price> priceLevels); Optional<Price> nextHigherLevel(final Price price); Optional<Price> nextLowerLevel(final Price price); int count(); Price get(final int index); boolean contains(final Price price); @Override String toString(); }
PriceLevels { public boolean contains(final Price price) { for (final Price level : priceLevels) { if (level.equals(price)) { return true; } } return false; } PriceLevels(final Price... priceLevels);  PriceLevels(final List<Price> priceLevels); Optional<Price> nextHigherLevel(final Price price); Optional<Price> nextLowerLevel(final Price price); int count(); Price get(final int index); boolean contains(final Price price); @Override String toString();  }