1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package ubic.basecode.ontology.model;
20
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24
25
26
27
28 public abstract class AbstractOntologyResource implements OntologyResource {
29
30 protected static Logger log = LoggerFactory.getLogger( AbstractOntologyResource.class );
31
32 private static final long serialVersionUID = 1L;
33
34 @Override
35 public int compareTo( OntologyResource other ) {
36 return this.getUri().compareTo( other.getUri() );
37 }
38
39 @Override
40 public boolean equals( Object obj ) {
41 if ( this == obj ) return true;
42 if ( obj == null ) return false;
43 if ( getClass() != obj.getClass() ) return false;
44 final AbstractOntologyResource other = ( AbstractOntologyResource ) obj;
45 if ( getLabel() == null ) {
46 if ( other.getLabel() != null ) return false;
47 } else if ( !getLabel().equals( other.getLabel() ) ) return false;
48 if ( getUri() == null ) {
49 if ( other.getUri() != null ) return false;
50 } else if ( !getUri().equals( other.getUri() ) ) return false;
51 return true;
52 }
53
54 @Override
55 public abstract String getUri();
56
57 @Override
58 public int hashCode() {
59 final int PRIME = 31;
60 int result = 1;
61 result = PRIME * result + ( ( getLabel() == null ) ? 0 : getLabel().hashCode() );
62 result = PRIME * result + ( ( getUri() == null ) ? 0 : getUri().hashCode() );
63 return result;
64 }
65
66 }