Revision d88833a9
Added by Patrick Plitzner about 5 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDTO.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.api.service.dto; |
10 | 10 |
|
11 |
import java.io.Serializable; |
|
12 |
import java.util.AbstractMap; |
|
11 | 13 |
import java.util.ArrayList; |
12 | 14 |
import java.util.Comparator; |
13 | 15 |
import java.util.HashSet; |
... | ... | |
15 | 17 |
import java.util.Set; |
16 | 18 |
import java.util.TreeSet; |
17 | 19 |
|
18 |
import org.hibernate.envers.tools.Pair; |
|
19 |
|
|
20 | 20 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
21 | 21 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
22 | 22 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
... | ... | |
41 | 41 |
|
42 | 42 |
private static final long serialVersionUID = -7597690654462090732L; |
43 | 43 |
|
44 |
private TreeSet<Pair<String, String>> characterData;
|
|
44 |
private TreeSet<AbstractMap.SimpleEntry<String, String>> characterData;
|
|
45 | 45 |
private DerivateDataDTO derivateDataDTO; |
46 | 46 |
protected String taxonName; |
47 | 47 |
protected String listLabel; |
... | ... | |
139 | 139 |
} |
140 | 140 |
|
141 | 141 |
public void setSpecimenTypeDesignations(Set<SpecimenTypeDesignation> specimenTypeDesignations) { |
142 |
this.specimenTypeDesignations = new HashSet(); |
|
142 |
this.specimenTypeDesignations = new HashSet<>();
|
|
143 | 143 |
for (SpecimenTypeDesignation typeDes: specimenTypeDesignations){ |
144 | 144 |
this.specimenTypeDesignations.add(typeDes); |
145 | 145 |
} |
... | ... | |
173 | 173 |
/** |
174 | 174 |
* @return the characterData |
175 | 175 |
*/ |
176 |
public TreeSet<Pair<String, String>> getCharacterData() {
|
|
176 |
public TreeSet<AbstractMap.SimpleEntry<String, String>> getCharacterData() {
|
|
177 | 177 |
return characterData; |
178 | 178 |
} |
179 | 179 |
|
180 | 180 |
public void addCharacterData(String character, String state){ |
181 | 181 |
if(characterData==null){ |
182 |
characterData = new TreeSet<Pair<String,String>>(new Comparator<Pair<String,String>>() { |
|
182 |
characterData = new TreeSet<AbstractMap.SimpleEntry<String,String>>(new PairComparator()); |
|
183 |
} |
|
184 |
characterData.add(new AbstractMap.SimpleEntry<>(character, state)); |
|
185 |
} |
|
183 | 186 |
|
184 |
@Override |
|
185 |
public int compare(Pair<String, String> o1, Pair<String, String> o2) { |
|
186 |
if(o1==null && o2!=null){ |
|
187 |
return -1; |
|
188 |
} |
|
189 |
if(o1!=null && o2==null){ |
|
190 |
return 1; |
|
191 |
} |
|
192 |
if(o1!=null && o2!=null){ |
|
193 |
return o1.getFirst().compareTo(o2.getFirst()); |
|
194 |
} |
|
195 |
return 0; |
|
187 |
private class PairComparator implements Comparator<AbstractMap.SimpleEntry<String,String>>, Serializable { |
|
188 |
|
|
189 |
private static final long serialVersionUID = -8589392050761963540L; |
|
190 |
|
|
191 |
@Override |
|
192 |
public int compare(AbstractMap.SimpleEntry<String, String> o1, AbstractMap.SimpleEntry<String, String> o2) { |
|
193 |
if(o1==null && o2!=null){ |
|
194 |
return -1; |
|
196 | 195 |
} |
197 |
}); |
|
198 |
} |
|
199 |
characterData.add(new Pair<String, String>(character, state)); |
|
196 |
if(o1!=null && o2==null){ |
|
197 |
return 1; |
|
198 |
} |
|
199 |
if(o1!=null && o2!=null){ |
|
200 |
return o1.getKey().compareTo(o2.getKey()); |
|
201 |
} |
|
202 |
return 0; |
|
203 |
} |
|
200 | 204 |
} |
201 | 205 |
|
202 | 206 |
/** |
Also available in: Unified diff
ref #8011 Fix serialization problem