2 * Copyright (C) 2009 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.
9 package eu
.etaxonomy
.taxeditor
.model
;
11 import java
.util
.Comparator
;
13 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
14 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
17 * Implements a {@link Comparator} for {@link DefinedTermBase} objects based on the term's label.
18 * The compare algorithm compares a term's label. Example: If used on an unsorted list of terms, the
19 * list will be alphabetically sorted by label afterwards.
25 public class DefaultTermComparator
<T
extends DefinedTermBase
> implements Comparator
<T
> {
27 public int compare(T o1
, T o2
) {
37 String label1
= o1
.getLabel(CdmStore
.getDefaultLanguage()) != null ? o1
.getLabel(CdmStore
.getDefaultLanguage()) : o1
.getTitleCache();
38 String label2
= o2
.getLabel(CdmStore
.getDefaultLanguage()) != null ? o2
.getLabel(CdmStore
.getDefaultLanguage()) : o2
.getTitleCache();
39 int result
= label1
.compareTo(label2
);
41 return o1
.getUuid().compareTo(o2
.getUuid());