Record Class City

java.lang.Object
java.lang.Record
com.maxmind.geoip2.record.City
Record Components:
locales - The locales to use for retrieving localized names.
confidence - A value from 0-100 indicating MaxMind's confidence that the city is correct. This attribute is only available from the Insights web service and the GeoIP2 Enterprise database.
geonameId - The GeoName ID for the city.
names - A Map from locale codes to the name in that locale.
All Implemented Interfaces:
JsonSerializable, NamedRecord

public record City(List<String> locales, Integer confidence, Long geonameId, Map<String,String> names) extends Record implements NamedRecord

City-level data associated with an IP address.

Do not use any of the city names as a database or map key. Use the value returned by geonameId() instead.

  • Constructor Details

    • City

      public City(List<String> locales, Integer confidence, Long geonameId, Map<String,String> names)
      Compact canonical constructor that ensures immutability and handles null values.
    • City

      public City()
      Constructs an instance of City with no data.
    • City

      public City(City city, List<String> locales)
      Constructs an instance of City.
      Parameters:
      city - The City object to copy.
      locales - The locales to use.
  • Method Details

    • getConfidence

      @Deprecated(since="5.0.0", forRemoval=true) public Integer getConfidence()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use confidence() instead. This method will be removed in 6.0.0.
      Returns:
      A value from 0-100 indicating MaxMind's confidence that the city is correct. This attribute is only available from the Insights web service and the GeoIP2 Enterprise database.
    • getGeoNameId

      @Deprecated(since="5.0.0", forRemoval=true) public Long getGeoNameId()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use geonameId() instead. This method will be removed in 6.0.0.
      Returns:
      The GeoName ID for the city.
    • getName

      @Deprecated(since="5.0.0", forRemoval=true) public String getName()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use NamedRecord.name() instead. This method will be removed in 6.0.0.
      Returns:
      The name of the city based on the locales list passed to the constructor.
    • getNames

      @Deprecated(since="5.0.0", forRemoval=true) public Map<String,String> getNames()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use names() instead. This method will be removed in 6.0.0.
      Returns:
      A Map from locale codes to the name in that locale.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • locales

      public List<String> locales()
      Returns the value of the locales record component.
      Specified by:
      locales in interface NamedRecord
      Returns:
      the value of the locales record component
    • confidence

      public Integer confidence()
      Returns the value of the confidence record component.
      Returns:
      the value of the confidence record component
    • geonameId

      public Long geonameId()
      Returns the value of the geonameId record component.
      Specified by:
      geonameId in interface NamedRecord
      Returns:
      the value of the geonameId record component
    • names

      public Map<String,String> names()
      Returns the value of the names record component.
      Specified by:
      names in interface NamedRecord
      Returns:
      the value of the names record component