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
.annotatedlineeditor
;
13 import java
.util
.Comparator
;
15 import org
.apache
.log4j
.Logger
;
17 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
20 * <p>IdentifiableEntityComparator class.</p>
26 public class IdentifiableEntityComparator
implements Comparator
{
27 private static final Logger logger
= Logger
28 .getLogger(IdentifiableEntityComparator
.class);
30 private boolean fIgnoreCase
;
32 private String
getTitleCache(Object o
) {
33 return o
== null || !(o
instanceof IdentifiableEntity
) ?
34 null : ((IdentifiableEntity
) o
).getTitleCache();
38 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
41 public int compare(Object o1
, Object o2
) {
42 String titleCache1
= getTitleCache(o1
);
43 String titleCache2
= getTitleCache(o2
);
44 if (titleCache1
== null && titleCache2
== null) {
47 if (titleCache1
== null) {
50 if (titleCache2
== null) {
53 return fIgnoreCase ? titleCache1
.compareToIgnoreCase(titleCache2
) :
54 titleCache1
.compareTo(titleCache2
);