CompositeGenotype implements Genotype, Iterable<Entry<K, V>> { @Override public String toString() { StringBuilder s = new StringBuilder("["); for (Entry<K, V> entry : this) { K key = entry.getKey(); V value = entry.getValue(); s.append(key).append("=").append(value).append(";"); } return s.append("]").toString(); } 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 toStringTest() { CompositeGenotype<String, Genotype> composite = new CompositeGenotype<String, Genotype>(); composite.put("one", new IntegerGenotype(0, 2)); composite.put("two", new IntegerGenotype(0, 2)); Assert.assertEquals("[one=[];two=[];]", composite.toString()); }