3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.model
;
12 import java
.util
.Comparator
;
14 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
15 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
18 * Implements a {@link Comparator} for {@link DefinedTermBase} objects based on the term's label.
19 * The compare algorithm compares a term's label. Example: If used on an unsorted list of terms, the
20 * list will be alphabetically sorted by label afterwards.
26 public class DefaultTermComparator
<T
extends DefinedTermBase
> implements Comparator
<T
> {
28 public int compare(T o1
, T o2
) {
38 String label1
= o1
.getLabel(CdmStore
.getDefaultLanguage()) != null ? o1
.getLabel(CdmStore
.getDefaultLanguage()) : o1
.getTitleCache();
39 String label2
= o2
.getLabel(CdmStore
.getDefaultLanguage()) != null ? o2
.getLabel(CdmStore
.getDefaultLanguage()) : o2
.getTitleCache();
40 return label1
.compareTo(label2
);