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
.bulkeditor
.input
.sortprovider
;
12 import java
.util
.Comparator
;
14 import eu
.etaxonomy
.cdm
.model
.common
.IIdentifiableEntity
;
17 * <p>IdentifiableEntityComparator class.</p>
23 public class TitleCacheComparator
<T
extends IIdentifiableEntity
> implements Comparator
<T
> {
25 private boolean fIgnoreCase
;
27 private String
getTitleCache(T o
) {
28 return o
== null ?
null : o
.getTitleCache();
32 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
35 public int compare(T o1
, T o2
) {
36 String titleCache1
= getTitleCache(o1
);
37 String titleCache2
= getTitleCache(o2
);
38 if (titleCache1
== null && titleCache2
== null) {
41 if (titleCache1
== null) {
44 if (titleCache2
== null) {
47 return fIgnoreCase ? titleCache1
.compareToIgnoreCase(titleCache2
) :
48 titleCache1
.compareTo(titleCache2
);