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.reversegeocoding;
24  
25  import com.gisgraphy.domain.geoloc.entity.HouseNumber;
26  
27  /**
28   * A simple dto
29   * 
30   * @author <a href="mailto:david.masclet@gisgraphy.com">David Masclet</a>
31   */
32  public class HouseNumberDistance {
33  	
34  	private HouseNumber houseNumber;
35  	private Double distance;
36  	
37  	public HouseNumberDistance(HouseNumber houseNumber,Double distance) {
38  		this.houseNumber = houseNumber;
39  		this.distance= distance;
40  	}
41  
42  	public HouseNumber getHouseNumber() {
43  		return houseNumber;
44  	}
45  
46  	public Double getDistance() {
47  		return distance;
48  	}
49  
50  	@Override
51  	public int hashCode() {
52  		final int prime = 31;
53  		int result = 1;
54  		result = prime * result
55  				+ ((distance == null) ? 0 : distance.hashCode());
56  		result = prime * result
57  				+ ((houseNumber == null) ? 0 : houseNumber.hashCode());
58  		return result;
59  	}
60  
61  	@Override
62  	//do not overide by generated IDE code, distance 
63  	public boolean equals(Object obj) {
64  		if (this == obj)
65  			return true;
66  		if (obj == null)
67  			return false;
68  		if (getClass() != obj.getClass())
69  			return false;
70  		HouseNumberDistance other = (HouseNumberDistance) obj;
71  		if (distance == null) {
72  			if (other.distance != null)
73  				return false;
74  		} else if (other.distance== null ||Math.abs(distance -other.distance)>0.001)
75  			return false;
76  		if (houseNumber == null) {
77  			if (other.houseNumber != null)
78  				return false;
79  		} else if (!houseNumber.equals(other.houseNumber))
80  			return false;
81  		return true;
82  	}
83  
84  }