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.
9 package eu
.etaxonomy
.cdm
.api
.service
;
11 import java
.util
.Comparator
;
14 import org
.apache
.commons
.lang
.StringUtils
;
16 import eu
.etaxonomy
.cdm
.common
.TreeNode
;
17 import eu
.etaxonomy
.cdm
.model
.description
.Distribution
;
18 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
20 public class DistributionNodeByAreaLabelComparator
implements Comparator
<TreeNode
<Set
<Distribution
>, NamedArea
>>{
22 public int compare(TreeNode
<Set
<Distribution
>, NamedArea
> node1
, TreeNode
<Set
<Distribution
>, NamedArea
> node2
) {
23 String label1
= node1
.getNodeId().getLabel();
24 String label2
= node2
.getNodeId().getLabel();
25 if (StringUtils
.isBlank(label1
)){
26 label1
= node1
.getNodeId().getUuid().toString();
28 if (StringUtils
.isBlank(label2
)){
29 label2
= node2
.getNodeId().getUuid().toString();
31 int result
= label1
.compareTo(label2
);
34 result
= node1
.getNodeId().getUuid().compareTo(node2
.getNodeId().getUuid());