Ignore:
Timestamp:
03/18/10 16:20:42 (14 years ago)
Author:
patdui
Message:
  • return descriptions sorted by default
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/ComponentDescription.java

    r127 r253  
    11package clarin.cmdi.componentregistry.model;
     2
     3import java.util.Comparator;
    24
    35import javax.xml.bind.annotation.XmlRootElement;
     
    911public class ComponentDescription extends AbstractDescription {
    1012
     13    public static final Comparator<? super ComponentDescription> COMPARE_ON_GROUP_AND_NAME = new Comparator<ComponentDescription>() {
     14        public int compare(ComponentDescription o1, ComponentDescription o2) {
     15            int result=0;
     16            if (o1.getGroupName() != null && o2.getGroupName() != null)
     17                result = o1.getGroupName().compareTo(o2.getGroupName());
     18            if (result == 0) {
     19                if (o1.getName() != null && o2.getName() != null) {
     20                    result = o1.getName().compareTo(o2.getName());
     21                } else {
     22                    result = o1.getId().compareTo(o2.getId());
     23                }
     24            }
     25            return result;
     26        }
     27    };
     28   
    1129    private String groupName;
    1230
Note: See TracChangeset for help on using the changeset viewer.