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 longitude identifier */ 026 public static final String LONGITUDE_IDENTIFIER = "longitude"; 027 028 /** The latitude identifier */ 029 public static final String LATITUDE_IDENTIFIER = "latitude"; 030 031 private Double _longitude; 032 private Double _latitude; 033 034 /** 035 * Constructs a Geocode 036 * @param longitude the longitude of the geocode 037 * @param latitude the latitude of the geocode 038 */ 039 public Geocode(Double longitude, Double latitude) 040 { 041 _longitude = longitude; 042 _latitude = latitude; 043 } 044 045 /** 046 * Retrieves the longitude 047 * @return the longitude 048 */ 049 public Double getLongitude() 050 { 051 return _longitude; 052 } 053 054 /** 055 * Retrieves the latitude 056 * @return the latitude 057 */ 058 public Double getLatitude() 059 { 060 return _latitude; 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}