View Javadoc
1   /*
2    * The basecode project
3    * 
4    * Copyright (c) 2007-2019 University of British Columbia
5    * 
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *       http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   *
18   */
19  package ubic.basecode.ontology.model;
20  
21  import org.slf4j.Logger;
22  import org.slf4j.LoggerFactory;
23  
24  /**
25   * @author pavlidis
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  }