2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.store
.model
;
12 import java
.util
.ArrayList
;
13 import java
.util
.Iterator
;
14 import java
.util
.List
;
17 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
23 * Retrieves the elements of a <code>Taxon</code>'s synonymy list, including misapplied names,
26 * Note: does not return an entry for the <code>Taxon</code> itself.
33 @SuppressWarnings("unchecked")
34 public class IterableSynonymyList
implements Iterable
<TaxonBase
> {
38 public IterableSynonymyList(Taxon taxon
) {
42 public Iterator
<TaxonBase
> iterator() {
43 return new TaxonIterator(taxon
);
46 class TaxonIterator
implements Iterator
<TaxonBase
> {
48 List
<TaxonBase
> synonymyList
;
51 public TaxonIterator(Taxon taxon
) {
52 synonymyList
= new ArrayList
<TaxonBase
>();
53 HomotypicalGroup homotypicGroup
= taxon
.getHomotypicGroup();
55 if (homotypicGroup
!= null) {
56 List
<Synonym
> homotypicSynonyms
= homotypicGroup
.getSynonymsInGroup(taxon
.getSec());
57 for (Synonym synonym
: homotypicSynonyms
) {
59 // Make sure synonym belongs to the taxon
60 if (synonym
.getAcceptedTaxa().contains(taxon
)) {
61 synonymyList
.add(synonym
);
66 List
<HomotypicalGroup
> heterotypicGroups
= taxon
.getHeterotypicSynonymyGroups();
67 for (HomotypicalGroup heterotypicGroup
: heterotypicGroups
) {
69 // Make sure this is not the taxon's homotypic group
70 if (!heterotypicGroup
.equals(homotypicGroup
)) {
72 List
<Synonym
> heterotypicSynonyms
= heterotypicGroup
.
73 getSynonymsInGroup(taxon
.getSec());
74 for (Synonym synonym
: heterotypicSynonyms
) {
76 // Make sure synonym belongs to the taxon
77 if (synonym
.getAcceptedTaxa().contains(taxon
)) {
78 synonymyList
.add(synonym
);
84 Set
<Taxon
> misappliedNames
= taxon
.getMisappliedNames();
85 for (Taxon misappliedName
: misappliedNames
) {
86 synonymyList
.add(misappliedName
);
91 public boolean hasNext() {
92 if (synonymyList
.size() == index
) {
98 public TaxonBase
<?
> next() {
99 TaxonBase
<?
> next
= synonymyList
.get(index
);
104 public void remove() {}