OSDN Git Service

a2b9530ce6099f6fe0e9e6c613c78f6b3542bb56
[stigmata/stigmata.git] / src / main / java / jp / sourceforge / stigmata / BirthmarkSpiComparator.java
1 package jp.sourceforge.stigmata;
2
3 /*
4  * $Id$
5  */
6
7 import java.util.Comparator;
8
9 import jp.sourceforge.stigmata.spi.BirthmarkSpi;
10
11 /**
12  * @author Haruaki TAMADA
13  * @version $Revision$ 
14  */
15 class BirthmarkSpiComparator implements Comparator<BirthmarkSpi>{
16     /**
17      * default constructor
18      */
19     public BirthmarkSpiComparator(){
20     }
21
22     public int hashCode(){
23         return System.identityHashCode(this);
24     }
25
26     public int compare(BirthmarkSpi s1, BirthmarkSpi s2){
27         if(s1.isExpert() && !s2.isExpert()){
28             return 1;
29         }
30         else if(!s1.isExpert() && s2.isExpert()){
31             return -1;
32         }
33         else{
34             return s1.getType().compareTo(s2.getType());
35         }
36     }
37
38     public boolean equals(Object o){
39         String className = null;
40         if(o != null){
41             className = o.getClass().getName();
42         }
43         return o != null && className.equals(getClass().getName());
44     }
45 }