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- AMapfrom 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 Summary
ConstructorsConstructorDescriptionCity()Constructs an instance ofCitywith no data.Constructs an instance ofCity.Compact canonical constructor that ensures immutability and handles null values. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theconfidencerecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thegeonameIdrecord component.Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.UsegeonameId()instead.getName()Deprecated, for removal: This API element is subject to removal in a future version.UseNamedRecord.name()instead.getNames()Deprecated, for removal: This API element is subject to removal in a future version.Usenames()instead.final inthashCode()Returns a hash code value for this object.locales()Returns the value of thelocalesrecord component.names()Returns the value of thenamesrecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from interface JsonSerializable
toJsonMethods inherited from interface NamedRecord
name
-
Constructor Details
-
City
-
City
public City()Constructs an instance ofCitywith no data. -
City
-
-
Method Details
-
getConfidence
Deprecated, for removal: This API element is subject to removal in a future version.Useconfidence()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, for removal: This API element is subject to removal in a future version.UsegeonameId()instead. This method will be removed in 6.0.0.- Returns:
- The GeoName ID for the city.
-
getName
Deprecated, for removal: This API element is subject to removal in a future version.UseNamedRecord.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
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
locales
-
confidence
Returns the value of theconfidencerecord component.- Returns:
- the value of the
confidencerecord component
-
geonameId
Returns the value of thegeonameIdrecord component.- Specified by:
geonameIdin interfaceNamedRecord- Returns:
- the value of the
geonameIdrecord component
-
names
-
confidence()instead.