001/*
002 *  Copyright 2018 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.cms.data;
017
018import java.util.Objects;
019
020/**
021 * Class containing geographic coordinates
022 */
023public class Geocode
024{
025    /** The latitude identifier */
026    public static final String LATITUDE_IDENTIFIER = "latitude";
027    
028    /** The longitude identifier */
029    public static final String LONGITUDE_IDENTIFIER = "longitude";
030
031    private Double _latitude;
032    private Double _longitude;
033    
034    /**
035     * Constructs a Geocode
036     * @param latitude the latitude of the geocode
037     * @param longitude the longitude of the geocode
038     */
039    public Geocode(Double latitude, Double longitude)
040    {
041        _latitude = latitude;
042        _longitude = longitude;
043    }
044    
045    /**
046     * Retrieves the latitude
047     * @return the latitude
048     */
049    public Double getLatitude()
050    {
051        return _latitude;
052    }
053    
054    /**
055     * Retrieves the longitude
056     * @return the longitude
057     */
058    public Double getLongitude()
059    {
060        return _longitude;
061    }
062
063    @Override
064    public int hashCode()
065    {
066        return Objects.hash(_latitude, _longitude);
067    }
068
069    @Override
070    public boolean equals(Object obj)
071    {
072        if (this == obj)
073        {
074            return true;
075        }
076        if (!(obj instanceof Geocode))
077        {
078            return false;
079        }
080        Geocode other = (Geocode) obj;
081        return Objects.equals(_latitude, other._latitude) && Objects.equals(_longitude, other._longitude);
082    }
083}