Class Location


  • public class Location
    extends java.lang.Object

    This class represents a location along with a range of 'names' which apply to it, such as countries, cities, postalCodes etc.

    The available fields are based closely on the MaxMind2 data.

    Since:
    13.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String city
      The city name of the represented location if it can be determined, otherwise null.
      private java.lang.String countryCode
      The two letter country code (ISO 3166-1 alpha code) of the represented location if it can be determined, otherwise null.
      private java.lang.Integer countryGeoNameId
      The GeoName ID of the country.
      private java.lang.String countryName
      The full country name of the represented location if it can be determined, otherwise null.
      private java.lang.Double latitude
      The latitude of the represented location.
      private java.lang.Double longitude
      The longitude of the represented location.
      private java.lang.Integer metroCode
      The metro code of the represented location if it can be determined, otherwise zero.
      private java.lang.String postalCode
      The postal code of the represented location if it can be determined, otherwise null.
      private java.util.List<Location.Subdivision> subdivisions
      The subdivisions of the location.
    • Constructor Summary

      Constructors 
      Constructor Description
      Location​(com.maxmind.geoip2.model.CityResponse location)
      Create a location from maxmind2 data One day we ought to handle locals, because China is not called China in China.
      Location​(java.lang.String city, java.lang.String countryCode, java.lang.String countryName, java.lang.Integer countryGeoNameId, java.lang.Double latitude, java.lang.Double longitude, java.lang.Integer metroCode, java.lang.String postalCode, java.util.List<Location.Subdivision> subdivisions)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Location.LocationBuilder builder()  
      protected boolean canEqual​(java.lang.Object other)  
      boolean equals​(java.lang.Object o)  
      java.lang.String getCity()
      The city name of the represented location if it can be determined, otherwise null.
      java.lang.String getCountryCode()
      The two letter country code (ISO 3166-1 alpha code) of the represented location if it can be determined, otherwise null.
      java.lang.Integer getCountryGeoNameId()
      The GeoName ID of the country.
      java.lang.String getCountryName()
      The full country name of the represented location if it can be determined, otherwise null.
      java.lang.Double getLatitude()
      The latitude of the represented location.
      java.lang.Double getLongitude()
      The longitude of the represented location.
      java.lang.Integer getMetroCode()
      The metro code of the represented location if it can be determined, otherwise zero.
      java.lang.String getPostalCode()
      The postal code of the represented location if it can be determined, otherwise null.
      java.util.List<Location.Subdivision> getSubdivisions()
      The subdivisions of the location.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • city

        private final java.lang.String city
        The city name of the represented location if it can be determined, otherwise null.
        Since:
        13.0
      • countryCode

        private final java.lang.String countryCode
        The two letter country code (ISO 3166-1 alpha code) of the represented location if it can be determined, otherwise null.
        Since:
        13.0
      • countryName

        private final java.lang.String countryName
        The full country name of the represented location if it can be determined, otherwise null.
        Since:
        13.0
      • countryGeoNameId

        private final java.lang.Integer countryGeoNameId
        The GeoName ID of the country.
        Since:
        15.24
      • latitude

        private final java.lang.Double latitude

        The latitude of the represented location.

        Defaults to zero if it cannot be determined even though that represents a legitimate location.

        Since:
        13.0
      • longitude

        private final java.lang.Double longitude

        The longitude of the represented location.

        Defaults to zero if it cannot be determined even though that represents a legitimate location.

        Since:
        13.0
      • metroCode

        private final java.lang.Integer metroCode
        The metro code of the represented location if it can be determined, otherwise zero.
        Since:
        13.0
      • postalCode

        private final java.lang.String postalCode
        The postal code of the represented location if it can be determined, otherwise null.
        Since:
        13.0
      • subdivisions

        private final java.util.List<Location.Subdivision> subdivisions
        The subdivisions of the location. This will generally hold the sate or province the location is in, however it depends on on the particular country. Some locations may have multiple subdivisions. The order is from the least specific to most specific division.
        Since:
        15.24
    • Constructor Detail

      • Location

        public Location​(com.maxmind.geoip2.model.CityResponse location)
        Create a location from maxmind2 data One day we ought to handle locals, because China is not called China in China.
        Parameters:
        location -
      • Location

        public Location​(java.lang.String city,
                        java.lang.String countryCode,
                        java.lang.String countryName,
                        java.lang.Integer countryGeoNameId,
                        java.lang.Double latitude,
                        java.lang.Double longitude,
                        java.lang.Integer metroCode,
                        java.lang.String postalCode,
                        java.util.List<Location.Subdivision> subdivisions)
    • Method Detail

      • getCity

        public java.lang.String getCity()
        The city name of the represented location if it can be determined, otherwise null.
        Since:
        13.0
      • getCountryCode

        public java.lang.String getCountryCode()
        The two letter country code (ISO 3166-1 alpha code) of the represented location if it can be determined, otherwise null.
        Since:
        13.0
      • getCountryName

        public java.lang.String getCountryName()
        The full country name of the represented location if it can be determined, otherwise null.
        Since:
        13.0
      • getCountryGeoNameId

        public java.lang.Integer getCountryGeoNameId()
        The GeoName ID of the country.
        Since:
        15.24
      • getLatitude

        public java.lang.Double getLatitude()

        The latitude of the represented location.

        Defaults to zero if it cannot be determined even though that represents a legitimate location.

        Since:
        13.0
      • getLongitude

        public java.lang.Double getLongitude()

        The longitude of the represented location.

        Defaults to zero if it cannot be determined even though that represents a legitimate location.

        Since:
        13.0
      • getMetroCode

        public java.lang.Integer getMetroCode()
        The metro code of the represented location if it can be determined, otherwise zero.
        Since:
        13.0
      • getPostalCode

        public java.lang.String getPostalCode()
        The postal code of the represented location if it can be determined, otherwise null.
        Since:
        13.0
      • getSubdivisions

        public java.util.List<Location.Subdivision> getSubdivisions()
        The subdivisions of the location. This will generally hold the sate or province the location is in, however it depends on on the particular country. Some locations may have multiple subdivisions. The order is from the least specific to most specific division.
        Since:
        15.24
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • canEqual

        protected boolean canEqual​(java.lang.Object other)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object