001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.search.geolocation;
016    
017    /**
018     * @author Michael C. Han
019     */
020    public class GeoLocationPoint {
021    
022            public GeoLocationPoint(double latitude, double longitude) {
023                    _latitude = latitude;
024                    _longitude = longitude;
025            }
026    
027            @Override
028            public boolean equals(Object obj) {
029                    if (this == obj) {
030                            return true;
031                    }
032    
033                    if (!(obj instanceof GeoLocationPoint)) {
034                            return false;
035                    }
036    
037                    GeoLocationPoint geoLocationPoint = (GeoLocationPoint)obj;
038    
039                    if (Double.compare(geoLocationPoint.getLatitude(), _latitude) != 0) {
040                            return false;
041                    }
042    
043                    if (Double.compare(geoLocationPoint.getLongitude(), _longitude) != 0) {
044                            return false;
045                    }
046    
047                    return true;
048            }
049    
050            public double getLatitude() {
051                    return _latitude;
052            }
053    
054            public double getLongitude() {
055                    return _longitude;
056            }
057    
058            @Override
059            public int hashCode() {
060                    long value = Double.doubleToLongBits(_latitude);
061    
062                    int hashCode = (int) (value ^ (value >>> 32));
063    
064                    value = Double.doubleToLongBits(_longitude);
065    
066                    hashCode = 31 * hashCode + (int) (value ^ (value >>> 32));
067    
068                    return hashCode;
069            }
070    
071            private final double _latitude;
072            private final double _longitude;
073    
074    }