CompositeGenotype implements Genotype, Iterable<Entry<K, V>> { @Override public int size() { int sum = 0; for (Genotype element : map.values()) { sum += element.size(); } return sum; } 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 size() { CompositeGenotype<String, Genotype> composite = new CompositeGenotype<String, Genotype>(); IntegerGenotype one = new IntegerGenotype(0, 2); one.add(1); IntegerGenotype two = new IntegerGenotype(0, 2); two.add(1); two.add(2); composite.put("one", one); composite.put("two", two); Assert.assertEquals(3, composite.size()); }