CompositeGenotype implements Genotype, Iterable<Entry<K, V>> { @Override @SuppressWarnings("unchecked") public <G extends Genotype> G newInstance() { try { return (G) this.getClass().newInstance(); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } CompositeGenotype();  CompositeGenotype(Map<K, V> map); @Override int size(); @SuppressWarnings("unchecked") G get(Object key); void put(K key, V value); void clear(); Set<K> keySet(); Collection<V> values(); @Override Iterator<Entry<K, V>> iterator(); @Override @SuppressWarnings("unchecked") G newInstance(); @Override String toString();  }
@Test public void newInstance() { CompositeGenotype<String, Genotype> composite = new CompositeGenotype<String, Genotype>(); composite.put("one", new IntegerGenotype(0, 2)); composite.put("two", new IntegerGenotype(0, 2)); CompositeGenotype<String, Genotype> composite2 = composite.newInstance(); Assert.assertEquals(0, composite2.size()); Assert.assertFalse(composite.equals(composite2)); }