View Javadoc
1   /*******************************************************************************
2    *   Gisgraphy Project 
3    * 
4    *   This library is free software; you can redistribute it and/or
5    *   modify it under the terms of the GNU Lesser General Public
6    *   License as published by the Free Software Foundation; either
7    *   version 2.1 of the License, or (at your option) any later version.
8    * 
9    *   This library is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   *   Lesser General Public License for more details.
13   * 
14   *   You should have received a copy of the GNU Lesser General Public
15   *   License along with this library; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
17   * 
18   *  Copyright 2008  Gisgraphy project 
19   *  David Masclet <davidmasclet@gisgraphy.com>
20   *  
21   *  
22   *******************************************************************************/
23  package com.gisgraphy.model;
24  
25  import java.io.Serializable;
26  
27  /**
28   * Base class for Model objects. Child objects should implement toString(),
29   * equals() and hashCode().
30   * 
31   * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
32   */
33  public abstract class BaseObject implements Serializable {
34  
35      /**
36       * Returns a multi-line String with key=value pairs.
37       * 
38       * @return a String representation of this class.
39       */
40      @Override
41      public abstract String toString();
42  
43      /**
44       * Compares object equality. When using Hibernate, the primary key should
45       * not be a part of this comparison.
46       * 
47       * @param o
48       *                object to compare to
49       * @return true/false based on equality tests
50       */
51      @Override
52      public abstract boolean equals(Object o);
53  
54      /**
55       * When you override equals, you should override hashCode. See "Why are
56       * equals() and hashCode() importation" for more information:
57       * http://www.hibernate.org/109.html
58       * 
59       * @return hashCode
60       */
61      @Override
62      public abstract int hashCode();
63  }