@Test(expected = IllegalArgumentException.class) public void testSetValueInvalidKey() { List<MockObject> keys = new ArrayList<>(); MockObject m1 = new MockObject(1); MockObject m2 = new MockObject(2); MockObject m3 = new MockObject(3); keys.add(m1); keys.add(m2); DoubleMapGenotype<MockObject> doubleMapGeno = new DoubleMapGenotype<>(keys, new MockBounds()); doubleMapGeno.setValue(m3, 1.0); }
@Override public void setValue(K key, Double value) { if (!containsKey(key)) { throw new IllegalArgumentException(MapGenotype.ERROR_MESSAGE_INVALID_KEY); } int i = keys.indexOf(key); if (value < bounds.getLowerBound(i) || value > bounds.getUpperBound(i)) { throw new IllegalArgumentException(MapGenotype.ERROR_MESSAGE_OUT_OF_BOUNDS); } while (size() <= i) { add(bounds.getLowerBound(i)); } set(i, value); }
DoubleMapGenotype extends DoubleGenotype implements MapGenotype<K, Double> { @Override public void setValue(K key, Double value) { if (!containsKey(key)) { throw new IllegalArgumentException(MapGenotype.ERROR_MESSAGE_INVALID_KEY); } int i = keys.indexOf(key); if (value < bounds.getLowerBound(i) || value > bounds.getUpperBound(i)) { throw new IllegalArgumentException(MapGenotype.ERROR_MESSAGE_OUT_OF_BOUNDS); } while (size() <= i) { add(bounds.getLowerBound(i)); } set(i, value); } }
DoubleMapGenotype extends DoubleGenotype implements MapGenotype<K, Double> { @Override public void setValue(K key, Double value) { if (!containsKey(key)) { throw new IllegalArgumentException(MapGenotype.ERROR_MESSAGE_INVALID_KEY); } int i = keys.indexOf(key); if (value < bounds.getLowerBound(i) || value > bounds.getUpperBound(i)) { throw new IllegalArgumentException(MapGenotype.ERROR_MESSAGE_OUT_OF_BOUNDS); } while (size() <= i) { add(bounds.getLowerBound(i)); } set(i, value); } DoubleMapGenotype(List<K> keys, Bounds<Double> bounds); }
DoubleMapGenotype extends DoubleGenotype implements MapGenotype<K, Double> { @Override public void setValue(K key, Double value) { if (!containsKey(key)) { throw new IllegalArgumentException(MapGenotype.ERROR_MESSAGE_INVALID_KEY); } int i = keys.indexOf(key); if (value < bounds.getLowerBound(i) || value > bounds.getUpperBound(i)) { throw new IllegalArgumentException(MapGenotype.ERROR_MESSAGE_OUT_OF_BOUNDS); } while (size() <= i) { add(bounds.getLowerBound(i)); } set(i, value); } DoubleMapGenotype(List<K> keys, Bounds<Double> bounds); void init(Random random); @Override void init(Random random, int n); @Override boolean containsKey(K key); @Override Double getValue(K key); @Override void setValue(K key, Double value); @Override @SuppressWarnings({ "unchecked", "rawtypes" }) G newInstance(); @Override String toString(); @Override int getIndexOf(K key); @Override Collection<K> getKeys(); }
DoubleMapGenotype extends DoubleGenotype implements MapGenotype<K, Double> { @Override public void setValue(K key, Double value) { if (!containsKey(key)) { throw new IllegalArgumentException(MapGenotype.ERROR_MESSAGE_INVALID_KEY); } int i = keys.indexOf(key); if (value < bounds.getLowerBound(i) || value > bounds.getUpperBound(i)) { throw new IllegalArgumentException(MapGenotype.ERROR_MESSAGE_OUT_OF_BOUNDS); } while (size() <= i) { add(bounds.getLowerBound(i)); } set(i, value); } DoubleMapGenotype(List<K> keys, Bounds<Double> bounds); void init(Random random); @Override void init(Random random, int n); @Override boolean containsKey(K key); @Override Double getValue(K key); @Override void setValue(K key, Double value); @Override @SuppressWarnings({ "unchecked", "rawtypes" }) G newInstance(); @Override String toString(); @Override int getIndexOf(K key); @Override Collection<K> getKeys();  }