3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.sortprovider
;
13 import java
.util
.Comparator
;
15 import eu
.etaxonomy
.cdm
.model
.common
.IIdentifiableEntity
;
18 * <p>IdentifiableEntityComparator class.</p>
24 public class TitleCacheComparator
<T
extends IIdentifiableEntity
> implements Comparator
<T
> {
26 private boolean fIgnoreCase
;
28 private String
getTitleCache(T o
) {
29 return o
== null ?
null : o
.getTitleCache();
33 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
36 public int compare(T o1
, T o2
) {
37 String titleCache1
= getTitleCache(o1
);
38 String titleCache2
= getTitleCache(o2
);
39 if (titleCache1
== null && titleCache2
== null) {
42 if (titleCache1
== null) {
45 if (titleCache2
== null) {
48 return fIgnoreCase ? titleCache1
.compareToIgnoreCase(titleCache2
) :
49 titleCache1
.compareTo(titleCache2
);